diff --git a/platform/unix/syspovfilesystem.cpp b/platform/unix/syspovfilesystem.cpp new file mode 100644 index 000000000..df7b5e4ed --- /dev/null +++ b/platform/unix/syspovfilesystem.cpp @@ -0,0 +1,175 @@ +//****************************************************************************** +/// +/// @file platform/unix/syspovfilesystem.cpp +/// +/// Unix-specific implementation of file system services. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "base/filesystem.h" +#include "syspovfilesystem.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POSIX standard header files +#include +#include + +// POV-Ray header files (base module) +#include "base/stringutilities.h" + +// this must be the last file included +#include "base/povassert.h" +#include "base/povdebug.h" + +namespace pov_base +{ + +namespace Filesystem +{ + +//****************************************************************************** + +#if !POV_USE_DEFAULT_DELETEFILE + +bool DeleteFile(const UCS2String& fileName) +{ + return (unlink(UCS2toSysString(fileName).c_str()) == 0); +} + +#endif // POV_USE_DEFAULT_DELETEFILE + +//****************************************************************************** + +#if !POV_USE_DEFAULT_LARGEFILE + +#ifndef POVUNIX_LSEEK64 +#define POVUNIX_LSEEK64(h,b,o) lseek(h,b,o) +#endif + +using Offset = decltype(POVUNIX_LSEEK64(0,0,0)); + +static_assert( + std::numeric_limits::digits > 32, + "Large files (> 2 GiB) not supported, limiting image size to approx. 100 Megapixels. Proceed at your own risk." + ); + +struct LargeFile::Data final +{ + int handle; + Data() : handle(-1) {} +}; + +LargeFile::LargeFile() : + mpData(new Data) +{} + +LargeFile::~LargeFile() +{ + Close(); +} + +bool LargeFile::CreateRW(const UCS2String& fileName) +{ + mpData->handle = open(UCS2toSysString(fileName).c_str(), + O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR); + return (mpData->handle != -1); +} + +bool LargeFile::Seek(std::int_least64_t offset) +{ + if (mpData->handle == -1) + return false; + if ((offset < 0) || (offset > std::numeric_limits::max())) + return false; + return (POVUNIX_LSEEK64(mpData->handle, Offset(offset), SEEK_SET) == offset); +} + +std::size_t LargeFile::Read(void* data, std::size_t maxSize) +{ + if (mpData->handle == -1) + return false; + return read(mpData->handle, data, int(maxSize)); +} + +bool LargeFile::Write(const void* data, std::size_t size) +{ + if (mpData->handle == -1) + return false; + return (write(mpData->handle, data, int(size)) == size); +} + +void LargeFile::Close() +{ + if (mpData->handle != -1) + { + close(mpData->handle); + mpData->handle = -1; + } +} + +#endif // POV_USE_DEFAULT_LARGEFILE + +//****************************************************************************** + +#if !POV_USE_DEFAULT_TEMPORARYFILE + +static UCS2String gTempPath; + +void SetTempFilePath(const UCS2String& tempPath) +{ + gTempPath = tempPath; +} + +UCS2String TemporaryFile::SuggestName() +{ + POV_ASSERT(!gTempPath.empty()); + + // TODO FIXME - This allows only one temporary file per process! + // TODO FIXME - Avoid converting back and forth between UCS-2 and system-specific encoding. + char str [POV_FILENAME_BUFFER_CHARS + 1] = ""; + std::snprintf(str, POV_FILENAME_BUFFER_CHARS + 1, "%spov%d", UCS2toSysString(gTempPath).c_str(), int(getpid())); + return SysToUCS2String(str); +} + +#endif // POV_USE_DEFAULT_TEMPORARYFILE + +//****************************************************************************** + +} +// end of namespace Filesystem + +} +// end of namespace pov_base diff --git a/platform/unix/syspovfilesystem.h b/platform/unix/syspovfilesystem.h new file mode 100644 index 000000000..501fc6fab --- /dev/null +++ b/platform/unix/syspovfilesystem.h @@ -0,0 +1,72 @@ +//****************************************************************************** +/// +/// @file platform/unix/syspovfilesystem.h +/// +/// Unix-specific declarations related to file system services. +/// +/// @note +/// Most of @ref platform/unix/syspovfilesystem.cpp is declared in +/// @ref base/filesystem.h. This file contains only a few extra +/// platform-specific declarations. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_UNIX_SYSPOVFILESYSTEM_H +#define POVRAY_UNIX_SYSPOVFILESYSTEM_H + +// Module config header file must be the first file included within POV-Ray unit header files +#include "base/configbase.h" + +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/stringtypes.h" + +namespace pov_base +{ + +namespace Filesystem +{ + +#if !POV_USE_DEFAULT_TEMPORARYFILE + +void SetTempFilePath(const UCS2String& tempPath); + +#endif // POV_USE_DEFAULT_TEMPORARYFILE + +} +// end of namespace Filesystem + +} +// end of namespace pov_base + +#endif // POVRAY_UNIX_SYSPOVFILESYSTEM_H diff --git a/platform/unix/syspovtimer.cpp b/platform/unix/syspovtimer.cpp index 13184847e..239a59316 100644 --- a/platform/unix/syspovtimer.cpp +++ b/platform/unix/syspovtimer.cpp @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -50,6 +50,7 @@ #include #endif +#include "base/povassert.h" #include "base/types.h" // this must be the last file included @@ -305,3 +306,4 @@ bool Timer::HasValidThreadCPUTime () const //****************************************************************************** } +// end of namespace pov_base diff --git a/platform/unix/syspovtimer.h b/platform/unix/syspovtimer.h index bd5a81e81..b70305ff4 100644 --- a/platform/unix/syspovtimer.h +++ b/platform/unix/syspovtimer.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -62,7 +62,7 @@ void Delay(unsigned int msec); /// in the order of an hour (any system with a 32-bit `clock_t` and a standard `CLOCKS_PER_SEC` /// of 1,000,000). /// -class Timer +class Timer final { public: @@ -105,5 +105,6 @@ class Timer #endif // !POV_USE_DEFAULT_TIMER } +// end of namespace pov_base #endif // POVRAY_UNIX_SYSPOVTIMER_H diff --git a/platform/windows/osversioninfo.cpp b/platform/windows/osversioninfo.cpp index a58eb3b7c..ecf60ebde 100644 --- a/platform/windows/osversioninfo.cpp +++ b/platform/windows/osversioninfo.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -60,3 +60,4 @@ bool WindowsVersionDetector::IsVersion (int major, int minor) const } } +// end of namespace pov_base diff --git a/platform/windows/osversioninfo.h b/platform/windows/osversioninfo.h index 8e7af9d2c..ee794d33c 100644 --- a/platform/windows/osversioninfo.h +++ b/platform/windows/osversioninfo.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -43,7 +43,7 @@ namespace pov_base { -class WindowsVersionDetector +class WindowsVersionDetector final { public: @@ -74,5 +74,6 @@ class WindowsVersionDetector }; } +// end of namespace pov_base #endif // POVRAY_WINDOWS_OSVERSIONINFO_H diff --git a/platform/windows/syspovfilesystem.cpp b/platform/windows/syspovfilesystem.cpp new file mode 100644 index 000000000..8c811f06d --- /dev/null +++ b/platform/windows/syspovfilesystem.cpp @@ -0,0 +1,212 @@ +//****************************************************************************** +/// +/// @file platform/windows/syspovfilesystem.cpp +/// +/// Windows-specific implementation of file system services. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "base/filesystem.h" + +// C++ variants of C standard header files +#include + +// C++ standard header files +#include + +// POSIX standard header files +#include +#include +#include + +// Windows API header files +#include + +// POV-Ray header files (base module) +#include "base/pov_err.h" +#include "base/stringutilities.h" + +// this must be the last file included +#include "base/povdebug.h" + +namespace pov_base +{ + +namespace Filesystem +{ + +#ifdef DeleteFile +#undef DeleteFile // Shame on you, Windows! +#endif + +// TODO - Consider using Windows API calls instead of POSIX-style functions +// (e.g. `CreateFileW()` instead of `_open()` or `_wopen()`). + +//****************************************************************************** + +#if !POV_USE_DEFAULT_DELETEFILE + +bool DeleteFile(const UCS2String& fileName) +{ + // TODO - use `_wunlink()` instead. + return (_unlink(UCS2toSysString(fileName).c_str()) == 0); +} + +#endif // POV_USE_DEFAULT_DELETEFILE + +//****************************************************************************** + +#if !POV_USE_DEFAULT_LARGEFILE + +using Offset = decltype(_lseeki64(0,0,0)); + +static_assert( + std::numeric_limits::digits > 32, + "Large files (> 2 GiB) not supported, limiting image size to approx. 100 Megapixels. Proceed at your own risk." + ); + +struct LargeFile::Data final +{ + int handle; + Data() : handle(-1) {} +}; + +LargeFile::LargeFile() : + mpData(new Data) +{} + +LargeFile::~LargeFile() +{ + Close(); +} + +bool LargeFile::CreateRW(const UCS2String& fileName) +{ + // TODO - use `_wopen()` instead. + mpData->handle = _open(UCS2toSysString(fileName).c_str(), + _O_CREAT | _O_RDWR | _O_TRUNC | _O_BINARY, _S_IREAD | _S_IWRITE); + return (mpData->handle != -1); +} + +bool LargeFile::Seek(std::int_least64_t offset) +{ + if (mpData->handle == -1) + return false; + if ((offset < 0) || (offset > std::numeric_limits::max())) + return false; + return (_lseeki64(mpData->handle, Offset(offset), SEEK_SET) == offset); +} + +std::size_t LargeFile::Read(void* data, std::size_t maxSize) +{ + if (mpData->handle == -1) + return false; + return _read(mpData->handle, data, int(maxSize)); +} + +bool LargeFile::Write(const void* data, std::size_t size) +{ + if (mpData->handle == -1) + return false; + return (_write(mpData->handle, data, int(size)) == size); +} + +void LargeFile::Close() +{ + if (mpData->handle != -1) + { + _close(mpData->handle); + mpData->handle = -1; + } +} + +#endif // POV_USE_DEFAULT_LARGEFILE + +//****************************************************************************** + +#if !POV_USE_DEFAULT_TEMPORARYFILE + +static std::wstring GetTempFilePath() +{ + static const auto maxTempPathLength = MAX_PATH - 14; // Leave space for the file names to be created. + static const auto* subdir = L"povwin\\"; + static const auto subdirLength = std::wcslen(subdir); + + // Get a maximum(!) estimate of the buffer size required (excluding terminating NUL). + auto bufferSizeRequired = GetTempPathW(0, nullptr); + if (bufferSizeRequired == 0) + throw POV_EXCEPTION(kUncategorizedError, "Could not get temp dir from Windows API"); + + // Now get the actual temp directory path. + std::wstring tempPath(bufferSizeRequired - 1, '\0'); + auto tempPathLength = GetTempPathW(bufferSizeRequired, const_cast(tempPath.c_str())); + if (tempPathLength == 0) + throw POV_EXCEPTION(kUncategorizedError, "Could not get temp dir from Windows API"); + if (tempPathLength >= bufferSizeRequired) + throw POV_EXCEPTION(kUncategorizedError, "Could not get temp dir from Windows API"); + tempPath.resize(tempPathLength); + + // Try to create a dedicated sub-directory for POV-Ray. + if (tempPathLength <= maxTempPathLength - subdirLength) + { + // Resulting path should be short enough for a sub-directory. + tempPath += subdir; + if ((CreateDirectoryW(tempPath.c_str(), nullptr) == 0) && (GetLastError() != ERROR_ALREADY_EXISTS)) + // We can't create the sub-directory, and it doesn't already exist either. + // Well, tough luck - we'll just dump our stuff in the main temp directory then. + // Roll back the addition of the sub-directory name. + tempPath.resize(tempPathLength); + } + + // That's it, we've officially chosen a directory to plonk our temporary files in. + return tempPath; +} + +UCS2String TemporaryFile::SuggestName() +{ + static const auto* prefix = L"pv"; + + static std::wstring tempPath(GetTempFilePath()); + wchar_t buffer[MAX_PATH]; + if (GetTempFileNameW(tempPath.c_str(), prefix, 0, buffer) == 0) + throw POV_EXCEPTION(kUncategorizedError, "Could not get temp file name from Windows API"); + return UCS2String(reinterpret_cast(buffer)); // TODO - this is actually UTF-16, not UCS-2. +} + +#endif // POV_USE_DEFAULT_TEMPORARYFILE + +//****************************************************************************** + +} +// end of namespace Filesystem + +} +// end of namespace pov_base diff --git a/platform/windows/syspovpath.cpp b/platform/windows/syspovpath.cpp index d45d864cd..0f92f432f 100644 --- a/platform/windows/syspovpath.cpp +++ b/platform/windows/syspovpath.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,6 +38,10 @@ // this must be the last file included #include "base/povdebug.h" +#include + +#include "base/stringtypes.h" + namespace pov_base { @@ -57,7 +61,7 @@ static inline bool IsParentDir(const UCS2String& s) return (s.length() == 2) && (s[0] == '.') && (s[1] == '.'); } -bool Path::ParsePathString (UCS2String& volume, vector& dirnames, UCS2String& filename, const UCS2String& path) +bool Path::ParsePathString (UCS2String& volume, std::vector& dirnames, UCS2String& filename, const UCS2String& path) { UCS2String stash; @@ -194,3 +198,4 @@ bool Path::ParsePathString (UCS2String& volume, vector& dirnames, UC //****************************************************************************** } +// end of namespace pov_base diff --git a/platform/windows/syspovpath.h b/platform/windows/syspovpath.h index bf5371958..055d83bce 100644 --- a/platform/windows/syspovpath.h +++ b/platform/windows/syspovpath.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -46,5 +46,6 @@ namespace pov_base // Currently there are no Windows-specific declarations. } +// end of namespace pov_base #endif // POVRAY_WINDOWS_SYSPOVPATH_H diff --git a/platform/windows/syspovtask.cpp b/platform/windows/syspovtask.cpp index 85f8940b7..003f9da16 100644 --- a/platform/windows/syspovtask.cpp +++ b/platform/windows/syspovtask.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -52,6 +52,7 @@ void WinMemThreadStartup(); void WinMemThreadCleanup(); } +// end of namespace povwin #endif @@ -75,6 +76,7 @@ static unsigned int GetNumberofCPUs (void) } } +// end of namespace vfeplatform namespace pov @@ -116,3 +118,4 @@ void Task::Cleanup () //****************************************************************************** } +// end of namespace pov diff --git a/platform/windows/syspovtask.h b/platform/windows/syspovtask.h index 94a274ae6..d960e2dbd 100644 --- a/platform/windows/syspovtask.h +++ b/platform/windows/syspovtask.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -46,5 +46,6 @@ namespace pov // Currently there are no Windows-specific declarations. } +// end of namespace pov #endif // POVRAY_WINDOWS_SYSPOVTASK_H diff --git a/platform/windows/syspovtimer.cpp b/platform/windows/syspovtimer.cpp index c2de78178..e4b793eb0 100644 --- a/platform/windows/syspovtimer.cpp +++ b/platform/windows/syspovtimer.cpp @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,12 +36,11 @@ #include "syspovtimer.h" -#include - #include #include #include +#include "base/povassert.h" #include "base/types.h" #include "osversioninfo.h" @@ -177,3 +176,4 @@ bool Timer::HasValidProcessCPUTime () const } } +// end of namespace pov_base diff --git a/platform/windows/syspovtimer.h b/platform/windows/syspovtimer.h index 521a46e42..d6610fdd4 100644 --- a/platform/windows/syspovtimer.h +++ b/platform/windows/syspovtimer.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -44,7 +44,7 @@ namespace pov_base void Delay(unsigned int msec); -class Timer +class Timer final { public: Timer(); @@ -73,5 +73,6 @@ class Timer }; } +// end of namespace pov_base #endif // POVRAY_WINDOWS_SYSPOVTIMER_H diff --git a/platform/x86/avx/avxnoise.cpp b/platform/x86/avx/avxnoise.cpp index 06552a63a..047b28bfb 100644 --- a/platform/x86/avx/avxnoise.cpp +++ b/platform/x86/avx/avxnoise.cpp @@ -16,7 +16,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -48,6 +48,8 @@ #include MACHINE_INTRINSICS_H #endif +#include "base/povassert.h" + #include "core/material/noise.h" /// @file @@ -529,6 +531,7 @@ void AVXDNoise(Vector3d& result, const Vector3d& EPoint) { POV_ASSERT(false); } #endif // DISABLE_OPTIMIZED_NOISE_AVX } +// end of namespace pov #endif // TRY_OPTIMIZED_NOISE_AVX diff --git a/platform/x86/avx/avxnoise.h b/platform/x86/avx/avxnoise.h index acaee324b..e7c766c5c 100644 --- a/platform/x86/avx/avxnoise.h +++ b/platform/x86/avx/avxnoise.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -58,6 +58,7 @@ DBL AVXNoise(const Vector3d& EPoint, int noise_generator); void AVXDNoise(Vector3d& result, const Vector3d& EPoint); } +// end of namespace pov #endif // TRY_OPTIMIZED_NOISE_AVX diff --git a/platform/x86/avx/avxportablenoise.cpp b/platform/x86/avx/avxportablenoise.cpp index fcb981380..96ffeec81 100644 --- a/platform/x86/avx/avxportablenoise.cpp +++ b/platform/x86/avx/avxportablenoise.cpp @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -37,6 +37,8 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "avxportablenoise.h" +#include "base/povassert.h" + #include "core/material/pattern.h" #include "core/material/texture.h" @@ -55,6 +57,7 @@ namespace pov { const bool kAVXPortableNoiseEnabled = true; } +// end of namespace pov #define PORTABLE_OPTIMIZED_NOISE #define PortableNoise AVXPortableNoise @@ -69,6 +72,7 @@ const bool kAVXPortableNoiseEnabled = false; DBL AVXPortableNoise(const Vector3d& EPoint, int noise_generator) { POV_ASSERT(false); return 0.0; } void AVXPortableDNoise(Vector3d& result, const Vector3d& EPoint) { POV_ASSERT(false); } } +// end of namespace pov #endif // DISABLE_OPTIMIZED_NOISE_AVX_PORTABLE diff --git a/platform/x86/avx/avxportablenoise.h b/platform/x86/avx/avxportablenoise.h index 870dfc0bd..63a2e8d05 100644 --- a/platform/x86/avx/avxportablenoise.h +++ b/platform/x86/avx/avxportablenoise.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -52,6 +52,7 @@ DBL AVXPortableNoise(const Vector3d& EPoint, int noise_generator); void AVXPortableDNoise(Vector3d& result, const Vector3d& EPoint); } +// end of namespace pov #endif // TRY_OPTIMIZED_NOISE_AVX_PORTABLE diff --git a/platform/x86/avx2fma3/avx2fma3noise.cpp b/platform/x86/avx2fma3/avx2fma3noise.cpp index db1e2b578..ba4b5827d 100644 --- a/platform/x86/avx2fma3/avx2fma3noise.cpp +++ b/platform/x86/avx2fma3/avx2fma3noise.cpp @@ -16,7 +16,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -48,6 +48,8 @@ #include MACHINE_INTRINSICS_H #endif +#include "base/povassert.h" + #include "core/material/noise.h" /// @file @@ -516,6 +518,7 @@ void AVX2FMA3DNoise(Vector3d& result, const Vector3d& EPoint) { POV_ASSERT(false #endif // DISABLE_OPTIMIZED_NOISE_AVX2FMA3 } +// end of namespace pov #endif // TRY_OPTIMIZED_NOISE_AVX2FMA3 diff --git a/platform/x86/avx2fma3/avx2fma3noise.h b/platform/x86/avx2fma3/avx2fma3noise.h index 7243fcb3d..4d217ca9c 100644 --- a/platform/x86/avx2fma3/avx2fma3noise.h +++ b/platform/x86/avx2fma3/avx2fma3noise.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -58,6 +58,7 @@ DBL AVX2FMA3Noise(const Vector3d& EPoint, int noise_generator); void AVX2FMA3DNoise(Vector3d& result, const Vector3d& EPoint); } +// end of namespace pov #endif // TRY_OPTIMIZED_NOISE_AVX2FMA3 diff --git a/platform/x86/avxfma4/avxfma4noise.cpp b/platform/x86/avxfma4/avxfma4noise.cpp index 20db191de..81740989d 100644 --- a/platform/x86/avxfma4/avxfma4noise.cpp +++ b/platform/x86/avxfma4/avxfma4noise.cpp @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -43,6 +43,8 @@ #include MACHINE_INTRINSICS_H #endif +#include "base/povassert.h" + #include "core/material/noise.h" /// @file @@ -417,6 +419,7 @@ void AVXFMA4DNoise(Vector3d& result, const Vector3d& EPoint) { POV_ASSERT(false) #endif // DISABLE_OPTIMIZED_NOISE_AVXFMA4 } +// end of namespace pov #endif // TRY_OPTIMIZED_NOISE_AVXFMA4 diff --git a/platform/x86/avxfma4/avxfma4noise.h b/platform/x86/avxfma4/avxfma4noise.h index bd71b3aab..541eb40c4 100644 --- a/platform/x86/avxfma4/avxfma4noise.h +++ b/platform/x86/avxfma4/avxfma4noise.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -56,6 +56,7 @@ DBL AVXFMA4Noise(const Vector3d& EPoint, int noise_generator); void AVXFMA4DNoise(Vector3d& result, const Vector3d& EPoint); } +// end of namespace pov #endif // TRY_OPTIMIZED_NOISE_AVXFMA4 diff --git a/platform/x86/cpuid.cpp b/platform/x86/cpuid.cpp index 5b38296ca..7c86b08ac 100644 --- a/platform/x86/cpuid.cpp +++ b/platform/x86/cpuid.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,13 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "cpuid.h" +// C++ variants of C standard header files #include +// C++ standard header files +#include + +// other 3rd party library header files #ifdef MACHINE_INTRINSICS_H #include MACHINE_INTRINSICS_H #endif @@ -142,7 +147,7 @@ enum CPUVendorId kCPUVendor_VM, }; -struct CPUVendorInfo +struct CPUVendorInfo final { CPUVendorId id; const char* cpuidString; @@ -162,7 +167,7 @@ CPUVendorInfo gCPUVendorInfo[] = { { kCPUVendor_Unrecognized, nullptr } }; -struct CPUIDInfo +struct CPUIDInfo final { CPUVendorId vendorId; bool xsave : 1; @@ -229,7 +234,7 @@ CPUIDInfo::CPUIDInfo() : } } -struct OSInfo +struct OSInfo final { bool xcr0_sse : 1; bool xcr0_avx : 1; @@ -256,7 +261,7 @@ OSInfo::OSInfo(const CPUIDInfo& cpuinfo) : /// does _not_ depend on the order of member-initializers in the constructor, /// but rather on the _order of declaration_. /// -struct CPUInfo::Data +struct CPUInfo::Data final { CPUIDInfo cpuidInfo; OSInfo osInfo; diff --git a/platform/x86/cpuid.h b/platform/x86/cpuid.h index 4824c8ee8..d403dd3f5 100644 --- a/platform/x86/cpuid.h +++ b/platform/x86/cpuid.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,7 +39,13 @@ #include "base/configbase.h" -class CPUInfo +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +class CPUInfo final { public: static bool SupportsSSE2(); ///< Test whether CPU and OS support SSE2. diff --git a/platform/x86/optimizednoise.cpp b/platform/x86/optimizednoise.cpp index 6ea010f9c..cdcda7127 100644 --- a/platform/x86/optimizednoise.cpp +++ b/platform/x86/optimizednoise.cpp @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -125,5 +125,6 @@ OptimizedNoiseInfo gaOptimizedNoiseInfo[] = { }; } +// end of namespace pov #endif // TRY_OPTIMIZED_NOISE diff --git a/source-doc/styleguide.md b/source-doc/styleguide.md index c4d50303a..d2c21687e 100644 --- a/source-doc/styleguide.md +++ b/source-doc/styleguide.md @@ -41,6 +41,8 @@ POV-Ray is being developed with portability high in mind. In practice and at pre - _Static Thread-Local Template Members_: Template classes _must not_ have thread-local static member variables. See the @ref PooledSimpleVector template class for a viable workaround. [XCode 8 and later, apparently still unresolved as of 2018-04-08] + - `std::floorf(float)`: This function _must not_ be used. Substitute `std::floor(float)` + instead. [GCC, apparently all versions as of 2019-02-11] - Source code should use the new features of C++11 with caution, as even some major compiler brands still have not achieved full compliance yet. The following constructs can be considered @@ -264,6 +266,14 @@ To test whether a smart pointer is (non-)null, do not unnecessarily clutter your with `NULL`, as that would lead to compile errors on some (perfectly C++11 compliant) compilers. +Classes +======= + + - All classes should be declared `final` unless specifically intended otherwise. + - All destructors of polymorphic classes should be declared `virtual`. + - All overriding methods (including destructors) should be declared both `virtual` and `override`. + + Miscellaneous Coding Rules ========================== diff --git a/source/backend/bounding/boundingtask.cpp b/source/backend/bounding/boundingtask.cpp index 3aa09564a..f05ae93bd 100644 --- a/source/backend/bounding/boundingtask.cpp +++ b/source/backend/bounding/boundingtask.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,22 +33,33 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/bounding/boundingtask.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include +// Boost header files #include #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/bounding/boundingtask.h" +// POV-Ray header files (base module) +// (none at the moment) +// POV-Ray header files (core module) #include "core/bounding/bsptree.h" #include "core/math/matrix.h" #include "core/scene/object.h" #include "core/scene/tracethreaddata.h" +// POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (backend module) #include "backend/scene/backendscenedata.h" #include "backend/support/task.h" @@ -58,7 +69,9 @@ namespace pov { -class SceneObjects : public BSPTree::Objects +using std::vector; + +class SceneObjects final : public BSPTree::Objects { public: vector infinite; @@ -81,28 +94,28 @@ class SceneObjects : public BSPTree::Objects } } - virtual ~SceneObjects() + virtual ~SceneObjects() override { // nothing to do } - virtual unsigned int size() const + virtual unsigned int size() const override { return finite.size(); } - virtual float GetMin(unsigned int axis, unsigned int i) const + virtual float GetMin(unsigned int axis, unsigned int i) const override { return finite[i]->BBox.lowerLeft[axis]; } - virtual float GetMax(unsigned int axis, unsigned int i) const + virtual float GetMax(unsigned int axis, unsigned int i) const override { return (finite[i]->BBox.lowerLeft[axis] + finite[i]->BBox.size[axis]); } }; -class BSPProgress : public BSPTree::Progress +class BSPProgress final : public BSPTree::Progress { public: BSPProgress(RenderBackend::SceneId sid, POVMSAddress addr, Task& task) : @@ -113,7 +126,7 @@ class BSPProgress : public BSPTree::Progress { } - virtual void operator()(unsigned int nodes) const + virtual void operator()(unsigned int nodes) const override { if((timer.ElapsedRealTime() - lastProgressTime) > 1000) // update progress at most every second { @@ -134,11 +147,11 @@ class BSPProgress : public BSPTree::Progress Timer timer; mutable POV_LONG lastProgressTime; - BSPProgress(); + BSPProgress() = delete; }; -BoundingTask::BoundingTask(shared_ptr sd, unsigned int bt, size_t seed) : - SceneTask(new TraceThreadData(dynamic_pointer_cast(sd), seed), boost::bind(&BoundingTask::SendFatalError, this, _1), "Bounding", sd), +BoundingTask::BoundingTask(std::shared_ptr sd, unsigned int bt, size_t seed) : + SceneTask(new TraceThreadData(std::dynamic_pointer_cast(sd), seed), boost::bind(&BoundingTask::SendFatalError, this, _1), "Bounding", sd), sceneData(sd), boundingThreshold(bt) { @@ -225,3 +238,4 @@ void BoundingTask::SendFatalError(Exception& e) } } +// end of namespace pov diff --git a/source/backend/bounding/boundingtask.h b/source/backend/bounding/boundingtask.h index 867a9209c..2c2fca067 100644 --- a/source/backend/bounding/boundingtask.h +++ b/source/backend/bounding/boundingtask.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,37 +36,49 @@ #ifndef POVRAY_BACKEND_BOUNDINGTASK_H #define POVRAY_BACKEND_BOUNDINGTASK_H -#include +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" -#include "backend/frame.h" -#include "backend/render/rendertask.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/base_fwd.h" + +// POV-Ray header files (core module) +#include "core/core_fwd.h" + +// POV-Ray header files (backend module) +#include "backend/scene/backendscenedata_fwd.h" +#include "backend/support/task.h" namespace pov { -class SceneData; -class TraceThreadData; - -class BoundingTask : public SceneTask +class BoundingTask final : public SceneTask { public: - BoundingTask(shared_ptr sd, unsigned int bt, size_t seed); - virtual ~BoundingTask(); + BoundingTask(std::shared_ptr sd, unsigned int bt, size_t seed); + virtual ~BoundingTask() override; - virtual void Run(); - virtual void Stopped(); - virtual void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; void AppendObject(ObjectPtr p); inline TraceThreadData *GetSceneDataPtr() { return reinterpret_cast(GetDataPtr()); } private: - shared_ptr sceneData; + std::shared_ptr sceneData; unsigned int boundingThreshold; void SendFatalError(pov_base::Exception& e); }; } +// end of namespace pov #endif // POVRAY_BACKEND_BOUNDINGTASK_H diff --git a/source/backend/configbackend.h b/source/backend/configbackend.h index f3663242c..1a2c63212 100644 --- a/source/backend/configbackend.h +++ b/source/backend/configbackend.h @@ -38,6 +38,7 @@ #ifndef POVRAY_BACKEND_CONFIGBACKEND_H #define POVRAY_BACKEND_CONFIGBACKEND_H +// Pull in other compile-time config header files first #include "base/configbase.h" #include "syspovconfigbackend.h" diff --git a/source/backend/control/benchmark.cpp b/source/backend/control/benchmark.cpp index 6886c24ea..7822e4bb2 100644 --- a/source/backend/control/benchmark.cpp +++ b/source/backend/control/benchmark.cpp @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -34,12 +34,21 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/control/benchmark.h" + +// C++ variants of C standard header files #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/control/benchmark.h" +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (backend module) #include "backend/control/benchmark_ini.h" #include "backend/control/benchmark_pov.h" @@ -78,4 +87,4 @@ unsigned int Get_Benchmark_Version (void) } } - +// end of namespace pov diff --git a/source/backend/control/benchmark.h b/source/backend/control/benchmark.h index 215c5ca97..3bc80de64 100644 --- a/source/backend/control/benchmark.h +++ b/source/backend/control/benchmark.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,8 +33,19 @@ /// //****************************************************************************** -#ifndef BENCHMARK_H -#define BENCHMARK_H +#ifndef POVRAY_BACKEND_BENCHMARK_H +#define POVRAY_BACKEND_BENCHMARK_H + +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (backend module) +// (none at the moment) namespace pov { @@ -47,5 +58,6 @@ bool Write_Benchmark_File (const char *Scene_File_Name, const char *INI_File_Nam unsigned int Get_Benchmark_Version (void) ; } +// end of namespace pov -#endif +#endif // POVRAY_BACKEND_BENCHMARK_H diff --git a/source/backend/control/messagefactory.cpp b/source/backend/control/messagefactory.cpp index 9842a86bf..48c8bc6b1 100644 --- a/source/backend/control/messagefactory.cpp +++ b/source/backend/control/messagefactory.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,17 +33,29 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/control/messagefactory.h" + +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// Boost header files #include #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/control/messagefactory.h" +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) +// (none at the moment) +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" #include "povms/povmsid.h" -#include "base/pov_err.h" +// POV-Ray header files (backend module) +// (none at the moment) // this must be the last file included #include "base/povdebug.h" @@ -130,3 +142,4 @@ void MessageFactory::SendMessage(MessageClass mc, WarningLevel level, const char } } +// end of namespace pov diff --git a/source/backend/control/messagefactory.h b/source/backend/control/messagefactory.h index ee5858233..481b0dc79 100644 --- a/source/backend/control/messagefactory.h +++ b/source/backend/control/messagefactory.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,11 +36,19 @@ #ifndef POVRAY_BACKEND_MESSAGEFACTORY_H #define POVRAY_BACKEND_MESSAGEFACTORY_H -#include "povms/povmscpp.h" -#include "povms/povmsid.h" +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/control/messagefactory_fwd.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/stringtypes.h" #include "base/messenger.h" +// POV-Ray header files (backend module) #include "backend/control/renderbackend.h" namespace pov @@ -48,12 +56,12 @@ namespace pov using namespace pov_base; -class MessageFactory : public GenericMessenger +class MessageFactory final : public GenericMessenger { public: MessageFactory(unsigned int wl, const char *sn, POVMSAddress saddr, POVMSAddress daddr, RenderBackend::SceneId sid, RenderBackend::ViewId vid); - virtual ~MessageFactory(); + virtual ~MessageFactory() override; private: @@ -67,5 +75,6 @@ class MessageFactory : public GenericMessenger }; } +// end of namespace pov #endif // POVRAY_BACKEND_MESSAGEFACTORY_H diff --git a/source/backend/control/messagefactory_fwd.h b/source/backend/control/messagefactory_fwd.h new file mode 100644 index 000000000..fbc19f26a --- /dev/null +++ b/source/backend/control/messagefactory_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file backend/control/messagefactory_fwd.h +/// +/// Forward declarations related to ... what? +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BACKEND_MESSAGEFACTORY_FWD_H +#define POVRAY_BACKEND_MESSAGEFACTORY_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class MessageFactory; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_MESSAGEFACTORY_FWD_H diff --git a/source/backend/control/parsertask.cpp b/source/backend/control/parsertask.cpp index 03a34d720..a07d44946 100644 --- a/source/backend/control/parsertask.cpp +++ b/source/backend/control/parsertask.cpp @@ -39,16 +39,23 @@ // C++ variants of C standard header files // C++ standard header files // Boost header files -// POV-Ray header files (base module) // (none at the moment) +// POV-Ray header files (base module) +#include "base/types.h" + // POV-Ray header files (core module) #include "core/scene/tracethreaddata.h" // POV-Ray header files (parser module) #include "parser/parser.h" +// POV-Ray header files (POVMS module) +#include "povms/povmscpp.h" +#include "povms/povmsid.h" + // POV-Ray header files (backend module) +#include "backend/control/messagefactory.h" #include "backend/scene/backendscenedata.h" // this must be the last file included @@ -69,7 +76,7 @@ ParserTask::ParserTask(std::shared_ptr sd, const ParserOptions void ParserTask::Run() { - mpParser.reset(new Parser(mpBackendSceneData, mOptions, messageFactory, *this, *this, *reinterpret_cast(GetDataPtr()))); + mpParser.reset(new Parser(mpBackendSceneData, mOptions, *mpMessageFactory, *this, *this, *reinterpret_cast(GetDataPtr()))); mpParser->Run(); } @@ -126,4 +133,5 @@ void ParserTask::ReportProgress(POV_LONG tokenCount) } } -} // end of namespace pov +} +// end of namespace pov diff --git a/source/backend/control/parsertask.h b/source/backend/control/parsertask.h index 3195f4374..bc8d786d0 100644 --- a/source/backend/control/parsertask.h +++ b/source/backend/control/parsertask.h @@ -51,7 +51,8 @@ // (none at the moment) // POV-Ray header files (parser module) -#include "parser/parser.h" +#include "parser/parser_fwd.h" +#include "parser/parsertypes.h" // POV-Ray header files (backend module) #include "backend/support/task.h" @@ -62,7 +63,7 @@ namespace pov using namespace pov_base; using namespace pov; -class ParserTask : public SceneTask, public pov_parser::Parser::FileResolver, public pov_parser::Parser::ProgressReporter +class ParserTask final : public SceneTask, public pov_parser::FileResolver, public pov_parser::ProgressReporter { public: @@ -77,7 +78,7 @@ class ParserTask : public SceneTask, public pov_parser::Parser::FileResolver, pu void SendFatalError(Exception& e); /// @} - /// @name @ref Parser::FileResolver related. + /// @name @ref pov_parser::FileResolver related. /// @{ virtual UCS2String FindFile(UCS2String parsedFileName, unsigned int fileType) override; @@ -85,7 +86,7 @@ class ParserTask : public SceneTask, public pov_parser::Parser::FileResolver, pu virtual OStream* CreateFile(const UCS2String& parsedFileName, unsigned int fileType, bool append) override; /// @} - /// @name @ref Parser::ProgressReporter related. + /// @name @ref pov_parser::ProgressReporter related. /// @{ static constexpr auto kMinProgressReportInterval = 1000; /// Minimum delay between progress reports (in milliseconds). @@ -101,6 +102,7 @@ class ParserTask : public SceneTask, public pov_parser::Parser::FileResolver, pu POV_LONG mLastProgressElapsedTime; }; -} // end of namespace pov +} +// end of namespace pov #endif // POVRAY_BACKEND_PARSERTASK_H diff --git a/source/backend/control/renderbackend.cpp b/source/backend/control/renderbackend.cpp index 67c60b133..8f80065fe 100644 --- a/source/backend/control/renderbackend.cpp +++ b/source/backend/control/renderbackend.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,15 +33,24 @@ /// //****************************************************************************** -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "backend/control/renderbackend.h" -#include "povms/povmscpp.h" -#include "povms/povmsid.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) +// (none at the moment) + +// POV-Ray header files (POVMS module) +#include "povms/povmscpp.h" +#include "povms/povmsid.h" + +// POV-Ray header files (backend module) #include "backend/povray.h" #include "backend/control/scene.h" #include "backend/scene/view.h" @@ -107,13 +116,13 @@ void RenderBackend::SendViewOutput(ViewId vid, POVMSAddress addr, POVMSType iden POVMS_SendMessage(RenderBackend::context, msg, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only! } -void RenderBackend::SendFindFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const vector& filenames, POVMSUCS2String& filename) +void RenderBackend::SendFindFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const std::vector& filenames, POVMSUCS2String& filename) { POVMS_Message msg(kPOVObjectClass_FileData, kPOVMsgClass_FileAccess, kPOVMsgIdent_FindFile); POVMS_Message result(kPOVObjectClass_FileData, kPOVMsgClass_FileAccess, kPOVMsgIdent_FindFile); POVMS_List files; - for(vector::const_iterator i(filenames.begin()); i != filenames.end(); i++) + for(std::vector::const_iterator i(filenames.begin()); i != filenames.end(); i++) { POVMS_Attribute attr(i->c_str()); files.Append(attr); @@ -304,7 +313,7 @@ void RenderBackend::CreateScene(POVMS_Message& msg, POVMS_Message& result, int) if(err != kNoErr) throw POV_EXCEPTION_CODE (err); - shared_ptr scene(new Scene(backendAddress, msg.GetSourceAddress(), scenecounter + 1)); + std::shared_ptr scene(new Scene(backendAddress, msg.GetSourceAddress(), scenecounter + 1)); scenecounter++; @@ -387,7 +396,7 @@ void RenderBackend::CreateView(POVMS_Message& msg, POVMS_Message& result, int) if(i == scenes.end()) throw POV_EXCEPTION_CODE(kInvalidIdentifierErr); - shared_ptr view(i->second->NewView(msg.TryGetInt(kPOVAttrib_Width, 160), msg.TryGetInt(kPOVAttrib_Height, 120), viewcounter + 1)); + std::shared_ptr view(i->second->NewView(msg.TryGetInt(kPOVAttrib_Width, 160), msg.TryGetInt(kPOVAttrib_Height, 120), viewcounter + 1)); viewcounter++; @@ -785,3 +794,4 @@ void RenderBackend::MakeDoneResult(POVMS_Message& result) } } +// end of namespace pov diff --git a/source/backend/control/renderbackend.h b/source/backend/control/renderbackend.h index 0bd103e84..f65172f69 100644 --- a/source/backend/control/renderbackend.h +++ b/source/backend/control/renderbackend.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,40 +36,52 @@ #ifndef POVRAY_BACKEND_RENDERBACKEND_H #define POVRAY_BACKEND_RENDERBACKEND_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include #include +#include +// POV-Ray header files (base module) +#include "base/stringtypes.h" + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" -#include "base/stringutilities.h" +// POV-Ray header files (backend module) +#include "backend/control/scene_fwd.h" +#include "backend/scene/view_fwd.h" namespace pov { using namespace pov_base; -class Scene; -class View; - /** * RenderBackend class receives render control messages from the * RenderFrontend class. Thee control messages are processed and * parsing, rendering or other operations are performed as * requested by the frontend. */ -class RenderBackend : public POVMS_MessageReceiver +class RenderBackend final : public POVMS_MessageReceiver { public: typedef POVMSInt SceneId; typedef POVMSInt ViewId; RenderBackend(POVMSContext ctx, bool (*val)(POVMSAddress)); - ~RenderBackend(); + virtual ~RenderBackend() override; static void SendSceneOutput(SceneId sid, POVMSAddress addr, POVMSType ident, POVMS_Object& obj); static void SendViewOutput(ViewId vid, POVMSAddress addr, POVMSType ident, POVMS_Object& obj); - static void SendFindFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const vector& filenames, UCS2String& filename); + static void SendFindFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const std::vector& filenames, UCS2String& filename); static void SendReadFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const UCS2String& filename, UCS2String& localfile, UCS2String& fileurl); static void SendCreatedFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const UCS2String& filename); @@ -113,11 +125,11 @@ class RenderBackend : public POVMS_MessageReceiver SceneId scenecounter; ViewId viewcounter; - typedef std::set ViewIdSet; - typedef std::map > SceneMap; - typedef std::map > ViewMap; - typedef std::map Scene2ViewsMap; - typedef std::map View2SceneMap; + typedef std::set ViewIdSet; + typedef std::map> SceneMap; + typedef std::map> ViewMap; + typedef std::map Scene2ViewsMap; + typedef std::map View2SceneMap; SceneMap scenes; ViewMap views; @@ -133,5 +145,6 @@ class RenderBackend : public POVMS_MessageReceiver }; } +// end of namespace pov #endif // POVRAY_BACKEND_RENDERBACKEND_H diff --git a/source/backend/control/scene.cpp b/source/backend/control/scene.cpp index 7b513abe2..f4dc518b9 100644 --- a/source/backend/control/scene.cpp +++ b/source/backend/control/scene.cpp @@ -33,21 +33,37 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/control/scene.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +// Boost header files #include #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/control/parsertask.h" -#include "backend/control/scene.h" +// POV-Ray header files (base module) +#include "base/image/colourspace.h" +// POV-Ray header files (core module) #include "core/scene/tracethreaddata.h" +// POV-Ray header files (POVMS module) +#include "povms/povmscpp.h" +#include "povms/povmsid.h" + +// POV-Ray header files (parser module) #include "parser/parsertypes.h" +// POV-Ray header files (backend module) #include "backend/bounding/boundingtask.h" +#include "backend/control/parsertask.h" +#include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" // this must be the last file included @@ -56,6 +72,9 @@ namespace pov { +using std::min; +using std::max; + Scene::Scene(POVMSAddress backendAddr, POVMSAddress frontendAddr, RenderBackend::SceneId sid) : sceneData(new BackendSceneData()), stopRequsted(false), @@ -76,7 +95,7 @@ Scene::~Scene() parserControlThread->join(); delete parserControlThread; - for(vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) + for(std::vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) delete (*i); sceneThreadData.clear(); } @@ -163,7 +182,7 @@ void Scene::StartParser(POVMS_Object& parseOptions) } // do parsing - sceneThreadData.push_back(dynamic_cast(parserTasks.AppendTask(new pov_parser::ParserTask( + sceneThreadData.push_back(dynamic_cast(parserTasks.AppendTask(new ParserTask( sceneData, pov_parser::ParserOptions(bool(parseOptions.Exist(kPOVAttrib_Clock)), parseOptions.TryGetFloat(kPOVAttrib_Clock, 0.0), seed) )))); @@ -223,7 +242,7 @@ bool Scene::Failed() return parserTasks.Failed(); } -shared_ptr Scene::NewView(unsigned int width, unsigned int height, RenderBackend::ViewId vid) +std::shared_ptr Scene::NewView(unsigned int width, unsigned int height, RenderBackend::ViewId vid) { if(parserTasks.IsDone() == false) throw POV_EXCEPTION_CODE(kNotNowErr); @@ -231,12 +250,17 @@ shared_ptr Scene::NewView(unsigned int width, unsigned int height, RenderB if((parserTasks.IsDone() == false) || (parserTasks.Failed() == true)) throw POV_EXCEPTION_CODE(kNotNowErr); - return shared_ptr(new View(sceneData, width, height, vid)); + return std::shared_ptr(new View(sceneData, width, height, vid)); +} + +POVMSAddress Scene::GetFrontendAddress() const +{ + return sceneData->frontendAddress; } void Scene::GetStatistics(POVMS_Object& parserStats) { - struct TimeData + struct TimeData final { POV_LONG cpuTime; POV_LONG realTime; @@ -247,7 +271,7 @@ void Scene::GetStatistics(POVMS_Object& parserStats) TimeData timeData[TraceThreadData::kMaxTimeType]; - for(vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) + for(std::vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) { timeData[(*i)->timeType].realTime = max(timeData[(*i)->timeType].realTime, (*i)->realTime); timeData[(*i)->timeType].cpuTime += (*i)->cpuTime; @@ -309,7 +333,7 @@ void Scene::SendStatistics(TaskQueue&) POVMS_SendMessage(parserStats); - for(vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) + for(std::vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) delete (*i); sceneThreadData.clear(); } @@ -352,3 +376,4 @@ void Scene::ParserControlThread() } } +// end of namespace pov diff --git a/source/backend/control/scene.h b/source/backend/control/scene.h index 0997702f4..f5c5f7826 100644 --- a/source/backend/control/scene.h +++ b/source/backend/control/scene.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,16 +36,30 @@ #ifndef POVRAY_BACKEND_SCENE_H #define POVRAY_BACKEND_SCENE_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/control/scene_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include -#include -#include +// Boost header files #include -#include "core/scene/tracethreaddata.h" +// POV-Ray header files (base module) +// (none at the moment) +// POV-Ray header files (core module) +#include "core/core_fwd.h" + +// POV-Ray header files (backend module) #include "backend/control/renderbackend.h" -#include "backend/scene/backendscenedata.h" +#include "backend/scene/backendscenedata_fwd.h" +#include "backend/scene/view_fwd.h" #include "backend/support/taskqueue.h" namespace pov @@ -53,13 +67,11 @@ namespace pov using namespace pov_base; -class View; - /// Class governing the rendering of a scene. /// /// @todo Change the class name into something more expressive. /// -class Scene +class Scene final { public: /** @@ -71,7 +83,7 @@ class Scene * each scene,once parsed, many views many be created, and * each view may specify different render quality, size and * camera parameters. This limitation may be lifted in the - * future to better support animationss and for example + * future to better support animations and for example * motion blur, but this can only be supported in POV-Ray * 4.0 when all the rendering code is rewritten! * @param backendAddr Address of the backend that owns this scene. @@ -93,7 +105,7 @@ class Scene * The frontend is notified by messages of the state * of parsing and all warnings and errors found. * Options shall be in a kPOVObjectClass_ParserOptions - * POVMS obect, which is created when parsing the INI + * POVMS object, which is created when parsing the INI * file or command line in the frontend. * @param parseOptions Options to use for parsing. */ @@ -120,7 +132,7 @@ class Scene /** * Resume parsing that has previously been stopped. - * If parsing is not paussed, no action is taken. + * If parsing is not paused, no action is taken. */ void ResumeParser(); @@ -153,13 +165,13 @@ class Scene * POVMS messages sent to the frontend. * @return New view bound to the scene's data. */ - shared_ptr NewView(unsigned int width, unsigned int height, RenderBackend::ViewId vid); + std::shared_ptr NewView(unsigned int width, unsigned int height, RenderBackend::ViewId vid); /** * Get the POVMS frontend address to send messages to the frontend. * @return Frontend address. */ - POVMSAddress GetFrontendAddress() const { return sceneData->frontendAddress; } + POVMSAddress GetFrontendAddress() const; /** * Get the current parser statistics for the scene. @@ -172,9 +184,9 @@ class Scene /// running and pending parser tasks for this scene TaskQueue parserTasks; /// scene thread data (e.g. statistics) - vector sceneThreadData; + std::vector sceneThreadData; /// scene data - shared_ptr sceneData; + std::shared_ptr sceneData; /// stop request flag bool stopRequsted; /// parser control thread @@ -199,5 +211,6 @@ class Scene }; } +// end of namespace pov #endif // POVRAY_BACKEND_SCENE_H diff --git a/source/backend/control/scene_fwd.h b/source/backend/control/scene_fwd.h new file mode 100644 index 000000000..62d5308c0 --- /dev/null +++ b/source/backend/control/scene_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file backend/control/scene_fwd.h +/// +/// Forward declarations related to ... what? +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BACKEND_SCENE_FWD_H +#define POVRAY_BACKEND_SCENE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class Scene; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_SCENE_FWD_H diff --git a/source/backend/frame.h b/source/backend/frame.h deleted file mode 100644 index ace5c20d2..000000000 --- a/source/backend/frame.h +++ /dev/null @@ -1,167 +0,0 @@ -//****************************************************************************** -/// -/// @file backend/frame.h -/// -/// Generic header for all back-end modules. -/// -/// This header file is included by all C++ modules in the POV-Ray back-end. -/// It defines various ubiquitous types and constants. -/// -/// @copyright -/// @parblock -/// -/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. -/// -/// POV-Ray is free software: you can redistribute it and/or modify -/// it under the terms of the GNU Affero General Public License as -/// published by the Free Software Foundation, either version 3 of the -/// License, or (at your option) any later version. -/// -/// POV-Ray 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 Affero General Public License for more details. -/// -/// You should have received a copy of the GNU Affero General Public License -/// along with this program. If not, see . -/// -/// ---------------------------------------------------------------------------- -/// -/// POV-Ray is based on the popular DKB raytracer version 2.12. -/// DKBTrace was originally written by David K. Buck. -/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. -/// -/// @endparblock -/// -//****************************************************************************** - -#ifndef FRAME_H -#define FRAME_H - -/// @file -/// -/// @todo The size of this file, and it being grouped into various thematical subsections, -/// indicate that its content should be split up into multiple files, to be included from -/// this one; furthermore, some contents may not really be that ubiquitous to warrant -/// including them in every module. - -#include - -#include -#include -#include - -#include - -#include "base/configbase.h" -#include "base/colour.h" -#include "base/types.h" - -#include "core/coretypes.h" -#include "core/bounding/boundingbox.h" - -#include "backend/configbackend.h" - -namespace pov -{ - -using namespace pov_base; - -// from ; we don't want to always type the namespace for these. -using std::min; -using std::max; - -// from ; we don't want to always type the namespace for these. -using std::abs; -using std::acos; -using std::asin; -using std::atan; -using std::atan2; -using std::ceil; -using std::cos; -using std::cosh; -using std::exp; -using std::fabs; -using std::floor; -using std::fmod; -using std::frexp; -using std::ldexp; -using std::log; -using std::log10; -using std::modf; -using std::pow; -using std::sin; -using std::sinh; -using std::sqrt; -using std::tan; -using std::tanh; - -//****************************************************************************** -/// -/// @name Forward Declarations -/// @{ - -class CompoundObject; - -class Intersection; -class Ray; - - -/// @} -/// -//****************************************************************************** -/// -/// @name Scalar, Colour and Vector Stuff -/// -/// @{ - -inline void Destroy_Float(DBL *x) -{ - if (x != nullptr) - delete x; -} - -/// @} -/// -//****************************************************************************** -/// -/// @name Object Stuff -/// -/// @{ - -#ifndef DUMP_OBJECT_DATA -#define DUMP_OBJECT_DATA 0 -#endif - -typedef struct Project_Struct PROJECT; -typedef struct Project_Tree_Node_Struct PROJECT_TREE_NODE; - -struct Project_Struct -{ - int x1, y1, x2, y2; -}; - -/* - * The following structure represent the bounding box hierarchy in 2d space. - * Because is_leaf, Object and Project are the first elements in both - * structures they can be accessed without knowing at which structure - * a pointer is pointing. - */ - -struct Project_Tree_Node_Struct -{ - unsigned short is_leaf; - BBOX_TREE *Node; - PROJECT Project; - unsigned short Entries; - PROJECT_TREE_NODE **Entry; -}; - -/// @} -/// -//****************************************************************************** - -} - -#endif diff --git a/source/backend/lighting/photonestimationtask.cpp b/source/backend/lighting/photonestimationtask.cpp index e2a0b9fbc..3a21510f1 100644 --- a/source/backend/lighting/photonestimationtask.cpp +++ b/source/backend/lighting/photonestimationtask.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -35,12 +35,19 @@ /// //****************************************************************************** -#include - -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "backend/lighting/photonestimationtask.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/lighting/lightsource.h" @@ -49,10 +56,12 @@ #include "core/shape/csg.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" #include "povms/povmsid.h" #include "povms/povmsutil.h" +// POV-Ray header files (backend module) #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" #include "backend/scene/viewthreaddata.h" @@ -63,6 +72,8 @@ namespace pov { +using std::vector; + PhotonEstimationTask::PhotonEstimationTask(ViewData *vd, size_t seed) : RenderTask(vd, seed, "Photon"), cooperate(*this) @@ -135,7 +146,7 @@ void PhotonEstimationTask::Finish() void PhotonEstimationTask::SearchThroughObjectsEstimatePhotons(vector& Objects, LightSource *Light) { ViewThreadData *renderDataPtr = GetViewDataPtr(); - shared_ptr sceneData = GetSceneData(); + std::shared_ptr sceneData = GetSceneData(); /* check this object and all siblings */ for(vector::iterator Sib = Objects.begin(); Sib != Objects.end(); Sib++) @@ -214,3 +225,4 @@ void PhotonEstimationTask::EstimatePhotonsForObjectAndLight(ObjectPtr Object, Li } } +// end of namespace pov diff --git a/source/backend/lighting/photonestimationtask.h b/source/backend/lighting/photonestimationtask.h index a14e0060a..6a9f2d868 100644 --- a/source/backend/lighting/photonestimationtask.h +++ b/source/backend/lighting/photonestimationtask.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,12 +33,25 @@ /// //****************************************************************************** -#ifndef PHOTONESTIMATIONTASK_H -#define PHOTONESTIMATIONTASK_H +#ifndef POVRAY_BACKEND_PHOTONESTIMATIONTASK_H +#define POVRAY_BACKEND_PHOTONESTIMATIONTASK_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/render/trace.h" -#include "backend/frame.h" +// POV-Ray header files (backend module) #include "backend/render/rendertask.h" namespace pov @@ -46,26 +59,26 @@ namespace pov using namespace pov_base; -class PhotonEstimationTask : public RenderTask +class PhotonEstimationTask final : public RenderTask { public: DBL photonCountEstimate; PhotonEstimationTask(ViewData *vd, size_t seed); - ~PhotonEstimationTask(); + virtual ~PhotonEstimationTask() override; - void Run(); - void Stopped(); - void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; - void SearchThroughObjectsEstimatePhotons(vector& Objects, LightSource *Light); + void SearchThroughObjectsEstimatePhotons(std::vector& Objects, LightSource *Light); void EstimatePhotonsForObjectAndLight(ObjectPtr Object, LightSource *Light); private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; @@ -74,4 +87,6 @@ class PhotonEstimationTask : public RenderTask }; } -#endif +// end of namespace pov + +#endif // POVRAY_BACKEND_PHOTONESTIMATIONTASK_H diff --git a/source/backend/lighting/photonshootingstrategy.cpp b/source/backend/lighting/photonshootingstrategy.cpp index 58f71f7d7..3c808c241 100644 --- a/source/backend/lighting/photonshootingstrategy.cpp +++ b/source/backend/lighting/photonshootingstrategy.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -35,12 +35,17 @@ /// //****************************************************************************** -#include - -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "backend/lighting/photonshootingstrategy.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/lighting/lightsource.h" @@ -53,6 +58,10 @@ #include "core/shape/csg.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) +// POV-Ray header files (backend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -74,7 +83,7 @@ PhotonShootingUnit* PhotonShootingStrategy::getNextUnit() return unit; } -void PhotonShootingStrategy::createUnitsForCombo(ObjectPtr obj, LightSource* light, shared_ptr sceneData) +void PhotonShootingStrategy::createUnitsForCombo(ObjectPtr obj, LightSource* light, std::shared_ptr sceneData) { PhotonShootingUnit* unit = new PhotonShootingUnit(light, obj); unit->lightAndObject.computeAnglesAndDeltas(sceneData); @@ -83,7 +92,7 @@ void PhotonShootingStrategy::createUnitsForCombo(ObjectPtr obj, LightSource* lig PhotonShootingStrategy::~PhotonShootingStrategy() { - vector::iterator delIter; + std::vector::iterator delIter; for(delIter = units.begin(); delIter != units.end(); delIter++) { delete (*delIter); @@ -91,5 +100,5 @@ PhotonShootingStrategy::~PhotonShootingStrategy() units.clear(); } - } +// end of namespace pov diff --git a/source/backend/lighting/photonshootingstrategy.h b/source/backend/lighting/photonshootingstrategy.h index 552f75cf9..6774b979a 100644 --- a/source/backend/lighting/photonshootingstrategy.h +++ b/source/backend/lighting/photonshootingstrategy.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,41 +33,56 @@ /// //****************************************************************************** -#ifndef PHOTONSHOOTINGSTRATEGY_H -#define PHOTONSHOOTINGSTRATEGY_H +#ifndef POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_H +#define POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/lighting/photonshootingstrategy_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// Boost header files #include -#include "backend/frame.h" +// POV-Ray header files (base module) +// (none at the moment) -namespace pov -{ +// POV-Ray header files (core module) +#include "core/core_fwd.h" -using namespace pov_base; +// POV-Ray header files (backend module) +// (none at the moment) -class PhotonShootingUnit; -class SceneData; +namespace pov +{ -class PhotonShootingStrategy +class PhotonShootingStrategy final { public: ObjectPtr obj; LightSource *light; - vector units; + std::vector units; - void createUnitsForCombo(ObjectPtr obj, LightSource* light, shared_ptr sceneData); + void createUnitsForCombo(ObjectPtr obj, LightSource* light, std::shared_ptr sceneData); void start(); PhotonShootingUnit* getNextUnit(); virtual ~PhotonShootingStrategy(); private: - vector::iterator iter; + std::vector::iterator iter; boost::mutex nextUnitMutex; }; } +// end of namespace pov -#endif +#endif // POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_H diff --git a/source/backend/lighting/photonshootingstrategy_fwd.h b/source/backend/lighting/photonshootingstrategy_fwd.h new file mode 100644 index 000000000..70f3a5e0e --- /dev/null +++ b/source/backend/lighting/photonshootingstrategy_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file backend/lighting/photonshootingstrategy_fwd.h +/// +/// Forward declarations related to ... what? +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_FWD_H +#define POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class PhotonShootingStrategy; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_FWD_H diff --git a/source/backend/lighting/photonshootingtask.cpp b/source/backend/lighting/photonshootingtask.cpp index 53ee3ce65..ce593ebb0 100644 --- a/source/backend/lighting/photonshootingtask.cpp +++ b/source/backend/lighting/photonshootingtask.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,12 +33,19 @@ /// //****************************************************************************** -#include - -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "backend/lighting/photonshootingtask.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/lighting/lightsource.h" @@ -48,10 +55,12 @@ #include "core/shape/csg.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" #include "povms/povmsid.h" #include "povms/povmsutil.h" +// POV-Ray header files (backend module) #include "backend/lighting/photonshootingstrategy.h" #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" @@ -357,7 +366,7 @@ void PhotonShootingTask::ShootPhotonsAtObject(LightTargetCombo& combo) //Initialize_Ray_Containers(&ray); ray.ClearInteriors (); - for(vector::iterator object = GetSceneData()->objects.begin(); object != GetSceneData()->objects.end(); object++) + for(std::vector::iterator object = GetSceneData()->objects.begin(); object != GetSceneData()->objects.end(); object++) { if ((*object)->Inside(ray.Origin, renderDataPtr) && ((*object)->interior != nullptr)) ray.AppendInterior((*object)->interior.get()); @@ -447,3 +456,4 @@ DBL PhotonShootingTask::computeAttenuation(const LightSource* Light, const Ray& } } +// end of namespace pov diff --git a/source/backend/lighting/photonshootingtask.h b/source/backend/lighting/photonshootingtask.h index 63d1f3eb1..87476cb90 100644 --- a/source/backend/lighting/photonshootingtask.h +++ b/source/backend/lighting/photonshootingtask.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,26 +33,32 @@ /// //****************************************************************************** -#ifndef PHOTONSHOOTINGTASK_H -#define PHOTONSHOOTINGTASK_H +#ifndef POVRAY_BACKEND_PHOTONSHOOTINGTASK_H +#define POVRAY_BACKEND_PHOTONSHOOTINGTASK_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/core_fwd.h" #include "core/lighting/photons.h" #include "core/render/trace.h" -#include "backend/frame.h" +// POV-Ray header files (backend module) +#include "backend/lighting/photonshootingstrategy_fwd.h" #include "backend/render/rendertask.h" namespace pov { -using namespace pov_base; - -class LightSource; -class LightTargetCombo; -class PhotonMap; -class PhotonShootingStrategy; - -class PhotonShootingTask : public RenderTask +class PhotonShootingTask final : public RenderTask { public: PhotonTrace trace; @@ -64,11 +70,11 @@ class PhotonShootingTask : public RenderTask RandomDoubleSequence::Generator randgen; PhotonShootingTask(ViewData *vd, PhotonShootingStrategy* strategy, size_t seed); - ~PhotonShootingTask(); + virtual ~PhotonShootingTask() override; - void Run(); - void Stopped(); - void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; void SendProgress(); @@ -78,11 +84,11 @@ class PhotonShootingTask : public RenderTask PhotonMap* getMediaPhotonMap(); PhotonMap* getSurfacePhotonMap(); private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; @@ -93,6 +99,7 @@ class PhotonShootingTask : public RenderTask DBL adcBailout; }; - } -#endif +// end of namespace pov + +#endif // POVRAY_BACKEND_PHOTONSHOOTINGTASK_H diff --git a/source/backend/lighting/photonsortingtask.cpp b/source/backend/lighting/photonsortingtask.cpp index d75b33518..b66c87cc5 100644 --- a/source/backend/lighting/photonsortingtask.cpp +++ b/source/backend/lighting/photonsortingtask.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,12 +33,17 @@ /// //****************************************************************************** -#include - -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "backend/lighting/photonsortingtask.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/lighting/lightsource.h" @@ -47,10 +52,13 @@ #include "core/shape/csg.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" #include "povms/povmsid.h" #include "povms/povmsutil.h" +// POV-Ray header files (backend module) +#include "backend/control/messagefactory.h" #include "backend/lighting/photonshootingstrategy.h" #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" @@ -71,8 +79,8 @@ namespace pov 3) compute gather options 4) clean up memory (delete the non-merged maps and delete the strategy) */ -PhotonSortingTask::PhotonSortingTask(ViewData *vd, const vector& surfaceMaps, - const vector& mediaMaps, PhotonShootingStrategy* strategy, +PhotonSortingTask::PhotonSortingTask(ViewData *vd, const std::vector& surfaceMaps, + const std::vector& mediaMaps, PhotonShootingStrategy* strategy, size_t seed) : RenderTask(vd, seed, "Photon"), surfaceMaps(surfaceMaps), @@ -117,7 +125,7 @@ void PhotonSortingTask::Run() else { if (!this->load()) - messageFactory.Error(POV_EXCEPTION_STRING("Failed to load photon map from disk"), "Could not load photon map (%s)",GetSceneData()->photonSettings.fileName.c_str()); + mpMessageFactory->Error(POV_EXCEPTION_STRING("Failed to load photon map from disk"), "Could not load photon map (%s)",GetSceneData()->photonSettings.fileName.c_str()); // set photon options automatically if (GetSceneData()->surfacePhotonMap.numPhotons>0) @@ -146,7 +154,7 @@ void PhotonSortingTask::Finish() void PhotonSortingTask::sortPhotonMap() { - vector::iterator mapIter; + std::vector::iterator mapIter; for(mapIter = surfaceMaps.begin(); mapIter != surfaceMaps.end(); mapIter++) { GetSceneData()->surfacePhotonMap.mergeMap(*mapIter); @@ -201,13 +209,13 @@ void PhotonSortingTask::sortPhotonMap() /* status bar for user */ // Send_Progress("Saving Photon Maps", PROGRESS_SAVING_PHOTON_MAPS); if (!this->save()) - messageFactory.Warning(kWarningGeneral,"Could not save photon map."); + mpMessageFactory->Warning(kWarningGeneral,"Could not save photon map."); } } else { if (!GetSceneData()->photonSettings.fileName.empty() && !GetSceneData()->photonSettings.loadFile) - messageFactory.Warning(kWarningGeneral,"Could not save photon map - no photons!"); + mpMessageFactory->Warning(kWarningGeneral,"Could not save photon map - no photons!"); } } @@ -257,7 +265,7 @@ bool PhotonSortingTask::save() } else { - messageFactory.PossibleError("Photon map for surface is empty."); + mpMessageFactory->PossibleError("Photon map for surface is empty."); } #ifdef GLOBAL_PHOTONS @@ -281,7 +289,7 @@ bool PhotonSortingTask::save() } else { - messageFactory.PossibleError("Global photon map is empty."); + mpMessageFactory->PossibleError("Global photon map is empty."); } #endif @@ -305,7 +313,7 @@ bool PhotonSortingTask::save() } else { - messageFactory.PossibleError("Photon map for media is empty."); + mpMessageFactory->PossibleError("Photon map for media is empty."); } fclose(f); @@ -336,7 +344,7 @@ bool PhotonSortingTask::load() if (!GetSceneData()->photonSettings.photonsEnabled) return false; - messageFactory.Warning(kWarningGeneral,"Starting the load of photon file %s\n",GetSceneData()->photonSettings.fileName.c_str()); + mpMessageFactory->Warning(kWarningGeneral,"Starting the load of photon file %s\n",GetSceneData()->photonSettings.fileName.c_str()); f = fopen(GetSceneData()->photonSettings.fileName.c_str(), "rb"); if (!f) @@ -398,5 +406,5 @@ bool PhotonSortingTask::load() return true; } - } +// end of namespace pov diff --git a/source/backend/lighting/photonsortingtask.h b/source/backend/lighting/photonsortingtask.h index de16eb32b..ed547fde3 100644 --- a/source/backend/lighting/photonsortingtask.h +++ b/source/backend/lighting/photonsortingtask.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,38 +33,47 @@ /// //****************************************************************************** -#ifndef PHOTONSORTINGTASK_H -#define PHOTONSORTINGTASK_H +#ifndef POVRAY_BACKEND_PHOTONSORTINGTASK_H +#define POVRAY_BACKEND_PHOTONSORTINGTASK_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "core/lighting/photons_fwd.h" + +// POV-Ray header files (core module) #include "core/render/trace.h" -#include "backend/frame.h" +// POV-Ray header files (backend module) +#include "backend/lighting/photonshootingstrategy_fwd.h" #include "backend/render/rendertask.h" namespace pov { -using namespace pov_base; - -class PhotonMap; -class PhotonShootingStrategy; - -class PhotonSortingTask : public RenderTask +class PhotonSortingTask final : public RenderTask { public: Timer timer; - vector surfaceMaps; - vector mediaMaps; + std::vector surfaceMaps; + std::vector mediaMaps; PhotonShootingStrategy* strategy; - PhotonSortingTask(ViewData *vd, const vector& surfaceMaps, const vector& mediaMaps, + PhotonSortingTask(ViewData *vd, const std::vector& surfaceMaps, const std::vector& mediaMaps, PhotonShootingStrategy* strategy, size_t seed); - ~PhotonSortingTask(); + virtual ~PhotonSortingTask() override; - void Run(); - void Stopped(); - void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; void SendProgress(); @@ -72,11 +81,11 @@ class PhotonSortingTask : public RenderTask bool save(); bool load(); private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; @@ -85,4 +94,6 @@ class PhotonSortingTask : public RenderTask }; } -#endif +// end of namespace pov + +#endif // POVRAY_BACKEND_PHOTONSORTINGTASK_H diff --git a/source/backend/lighting/photonstrategytask.cpp b/source/backend/lighting/photonstrategytask.cpp index 0f64816c4..aab0f715b 100644 --- a/source/backend/lighting/photonstrategytask.cpp +++ b/source/backend/lighting/photonstrategytask.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,12 +33,19 @@ /// //****************************************************************************** -#include - -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "backend/lighting/photonstrategytask.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/lighting/lightsource.h" @@ -47,10 +54,13 @@ #include "core/shape/csg.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" #include "povms/povmsid.h" #include "povms/povmsutil.h" +// POV-Ray header files (backend module) +#include "backend/control/messagefactory.h" #include "backend/lighting/photonshootingstrategy.h" #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" @@ -62,6 +72,8 @@ namespace pov { +using std::vector; + PhotonStrategyTask::PhotonStrategyTask(ViewData *vd, PhotonShootingStrategy* strategy, size_t seed) : RenderTask(vd, seed, "Photon"), strategy(strategy), @@ -100,7 +112,7 @@ void PhotonStrategyTask::Run() if ((*Light)->Light_Type != FILL_LIGHT_SOURCE) { if ((*Light)->Light_Type == CYLINDER_SOURCE && !(*Light)->Parallel) - messageFactory.Warning(kWarningGeneral,"Cylinder lights should be parallel when used with photons."); + mpMessageFactory->Warning(kWarningGeneral,"Cylinder lights should be parallel when used with photons."); /* do object-specific lighting */ SearchThroughObjectsCreateUnits(GetSceneData()->objects, (*Light)); @@ -118,7 +130,7 @@ void PhotonStrategyTask::Run() Light = Light_Group_Light->Light; if (Light->Light_Type == CYLINDER_SOURCE && !Light->Parallel) - messageFactory.Warning(kWarningGeneral,"Cylinder lights should be parallel when used with photons."); + mpMessageFactory->Warning(kWarningGeneral,"Cylinder lights should be parallel when used with photons."); // do object-specific lighting SearchThroughObjectsCreateUnits(GetSceneData()->objects, Light); @@ -169,7 +181,7 @@ void PhotonStrategyTask::Finish() void PhotonStrategyTask::SearchThroughObjectsCreateUnits(vector& Objects, LightSource *Light) { - shared_ptr sceneData = GetSceneData(); + std::shared_ptr sceneData = GetSceneData(); /* check this object and all siblings */ for(vector::iterator Sib = Objects.begin(); Sib != Objects.end(); Sib++) @@ -194,5 +206,5 @@ void PhotonStrategyTask::SearchThroughObjectsCreateUnits(vector& Obje } } - } +// end of namespace pov diff --git a/source/backend/lighting/photonstrategytask.h b/source/backend/lighting/photonstrategytask.h index 1708d0d25..15cdae641 100644 --- a/source/backend/lighting/photonstrategytask.h +++ b/source/backend/lighting/photonstrategytask.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,22 +33,32 @@ /// //****************************************************************************** -#ifndef PHOTONSTRATEGYTASK_H -#define PHOTONSTRATEGYTASK_H +#ifndef POVRAY_BACKEND_PHOTONSTRATEGYTASK_H +#define POVRAY_BACKEND_PHOTONSTRATEGYTASK_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/render/trace.h" -#include "backend/frame.h" +// POV-Ray header files (backend module) +#include "backend/lighting/photonshootingstrategy_fwd.h" #include "backend/render/rendertask.h" namespace pov { -using namespace pov_base; - -class PhotonShootingStrategy; - -class PhotonStrategyTask : public RenderTask +class PhotonStrategyTask final : public RenderTask { public: Timer timer; @@ -56,21 +66,21 @@ class PhotonStrategyTask : public RenderTask PhotonShootingStrategy* strategy; PhotonStrategyTask(ViewData *vd, PhotonShootingStrategy* strategy, size_t seed); - ~PhotonStrategyTask(); + virtual ~PhotonStrategyTask() override; - void Run(); - void Stopped(); - void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; void SendProgress(); - void SearchThroughObjectsCreateUnits(vector& Objects, LightSource *Light); + void SearchThroughObjectsCreateUnits(std::vector& Objects, LightSource *Light); private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; @@ -79,4 +89,6 @@ class PhotonStrategyTask : public RenderTask }; } -#endif +// end of namespace pov + +#endif // POVRAY_BACKEND_PHOTONSTRATEGYTASK_H diff --git a/source/backend/povray.cpp b/source/backend/povray.cpp index b38f00bd7..7b7690db7 100644 --- a/source/backend/povray.cpp +++ b/source/backend/povray.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,27 +33,36 @@ /// //****************************************************************************** -#include -#include +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/povray.h" +// C++ variants of C standard header files #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/povray.h" +// C++ standard header files +#include -#include "povms/povmscpp.h" -#include "povms/povmsid.h" -#include "povms/povmsutil.h" +// Boost header files +#include +#include +// POV-Ray header files (base module) #include "base/platformbase.h" #include "base/pov_err.h" +#include "base/stringutilities.h" #include "base/timer.h" #include "base/types.h" +// POV-Ray header files (core module) #include "core/material/noise.h" #include "core/material/pattern.h" +// POV-Ray header files (POVMS module) +#include "povms/povmscpp.h" +#include "povms/povmsid.h" +#include "povms/povmsutil.h" + +// POV-Ray header files (backend module) #include "backend/control/renderbackend.h" #include "backend/support/task.h" @@ -508,7 +517,7 @@ void BuildInitInfo(POVMSObjectPtr msg) { #ifdef TRY_OPTIMIZED_NOISE const OptimizedNoiseInfo* pNoise = GetRecommendedOptimizedNoise(); - std::string noiseGenInfo = "Noise generator: " + std::string(pNoise->name) + " (" + ::string(pNoise->info) + ")"; + std::string noiseGenInfo = "Noise generator: " + std::string(pNoise->name) + " (" + std::string(pNoise->info) + ")"; err = POVMSAttr_New(&attr); if (err == kNoErr) { diff --git a/source/backend/povray.h b/source/backend/povray.h index 984a55086..eb53108da 100644 --- a/source/backend/povray.h +++ b/source/backend/povray.h @@ -14,7 +14,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -42,12 +42,22 @@ #ifndef POVRAY_BACKEND_POVRAY_H #define POVRAY_BACKEND_POVRAY_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// Boost header files #include #include +// POV-Ray header files (base module) #include "base/version_info.h" -#include "povms/povmscpp.h" +// POV-Ray header files (backend module) +// (none at the moment) /** * This function does essential initialisation that is required before diff --git a/source/backend/precomp.h b/source/backend/precomp.h index 95c341178..f9397f771 100644 --- a/source/backend/precomp.h +++ b/source/backend/precomp.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "base/configbase.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,13 +70,11 @@ #include #include +// Boost header files #include #include #include #include -#include -#include -#include #if POV_MULTITHREADED #include #include diff --git a/source/backend/render/radiositytask.cpp b/source/backend/render/radiositytask.cpp index 6472f6bb3..fc706957e 100644 --- a/source/backend/render/radiositytask.cpp +++ b/source/backend/render/radiositytask.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,16 +33,29 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/render/radiositytask.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// Boost header files #include #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/render/radiositytask.h" - +// POV-Ray header files (base module) #include "base/timer.h" #include "base/types.h" +// POV-Ray header files (core module) +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (backend module) #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" #include "backend/scene/viewthreaddata.h" @@ -55,6 +68,9 @@ namespace pov using namespace pov_base; +using std::min; +using std::max; + RadiosityTask::RadiosityTask(ViewData *vd, DBL ptsz, DBL ptesz, unsigned int pts, unsigned int ptsc, unsigned int nt, size_t seed) : RenderTask(vd, seed, "Radiosity", vd->GetViewId()), @@ -89,8 +105,8 @@ void RadiosityTask::Run() DBL height = GetViewData()->GetHeight(); POVRect rect; - vector pixelpositions; - vector pixelcolors; + std::vector pixelpositions; + std::vector pixelcolors; unsigned int serial; float progressWeightTotal = (pow(4.0f, (float)pretraceStepCount) - 1.0) / 3.0; // equal to SUM[i=0,N-1](pow(4.0, i)) @@ -261,3 +277,4 @@ void RadiosityTask::Finish() } } +// end of namespace pov diff --git a/source/backend/render/radiositytask.h b/source/backend/render/radiositytask.h index 55873eaa6..299428028 100644 --- a/source/backend/render/radiositytask.h +++ b/source/backend/render/radiositytask.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,41 +36,54 @@ #ifndef POVRAY_BACKEND_RADIOSITYTASK_H #define POVRAY_BACKEND_RADIOSITYTASK_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/lighting/photons.h" #include "core/lighting/radiosity.h" #include "core/material/media.h" #include "core/render/tracepixel.h" +// POV-Ray header files (backend module) #include "backend/render/rendertask.h" #include "backend/scene/view.h" namespace pov { -class RadiosityTask : public RenderTask +class RadiosityTask final : public RenderTask { public: RadiosityTask(ViewData *vd, DBL ptsz, DBL ptesz, unsigned int pts, unsigned int ptsc, unsigned int nt, size_t seed); - virtual ~RadiosityTask(); + virtual ~RadiosityTask() override; - virtual void Run(); - virtual void Stopped(); - virtual void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; - struct RadiositySubBlockInfo { + struct RadiositySubBlockInfo final + { RadiositySubBlockInfo(unsigned short x, unsigned short y): subBlockPosX(x), subBlockPosY(y) {} unsigned short subBlockPosX, subBlockPosY; }; - class RadiosityBlockInfo : public ViewData::BlockInfo + class RadiosityBlockInfo final : public ViewData::BlockInfo { public: RadiosityBlockInfo(): pass(0), subBlockCountX(1), subBlockCountY(1), completion(0.0) @@ -104,6 +117,6 @@ class RadiosityTask : public RenderTask }; } +// end of namespace pov #endif // POVRAY_BACKEND_RADIOSITYTASK_H - diff --git a/source/backend/render/rendertask.cpp b/source/backend/render/rendertask.cpp index 2d3b3c210..9219624bc 100644 --- a/source/backend/render/rendertask.cpp +++ b/source/backend/render/rendertask.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,18 +33,28 @@ /// //****************************************************************************** -#include -#include +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/render/rendertask.h" -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) -#include "povms/povmsid.h" +// Boost header files +#include +#include +// POV-Ray header files (base module) #include "base/types.h" #include "base/timer.h" -#include "backend/render/rendertask.h" +// POV-Ray header files (core module) +// (none at the moment) + +// POV-Ray header files (POVMS module) +#include "povms/povmsid.h" + +// POV-Ray header files (backend module) #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" #include "backend/scene/viewthreaddata.h" @@ -67,7 +77,7 @@ RenderTask::~RenderTask() { } -shared_ptr& RenderTask::GetSceneData() +std::shared_ptr& RenderTask::GetSceneData() { return viewData->GetSceneData(); } @@ -95,3 +105,4 @@ void RenderTask::SendFatalError(Exception& e) } } +// end of namespace pov diff --git a/source/backend/render/rendertask.h b/source/backend/render/rendertask.h index 8d9371df4..51f3c2ada 100644 --- a/source/backend/render/rendertask.h +++ b/source/backend/render/rendertask.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,25 +36,36 @@ #ifndef POVRAY_BACKEND_RENDERTASK_H #define POVRAY_BACKEND_RENDERTASK_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "core/core_fwd.h" + +// POV-Ray header files (backend module) +#include "backend/scene/view_fwd.h" +#include "backend/scene/viewthreaddata_fwd.h" #include "backend/support/task.h" namespace pov { -class SceneData; -class ViewData; -class ViewThreadData; - class RenderTask : public SceneTask { public: RenderTask(ViewData *vd, size_t seed, const char* sn, RenderBackend::ViewId vid = 0); - virtual ~RenderTask(); + virtual ~RenderTask() override; protected: - virtual void Run() = 0; - virtual void Stopped() = 0; + virtual void Run() override = 0; + virtual void Stopped() override = 0; - shared_ptr& GetSceneData(); + std::shared_ptr& GetSceneData(); ViewData *GetViewData(); inline ViewThreadData *GetViewDataPtr() { return reinterpret_cast(GetDataPtr()); } @@ -66,5 +77,6 @@ class RenderTask : public SceneTask }; } +// end of namespace pov #endif // POVRAY_BACKEND_RENDERTASK_H diff --git a/source/backend/render/tracetask.cpp b/source/backend/render/tracetask.cpp index 64a1b70b9..063404981 100644 --- a/source/backend/render/tracetask.cpp +++ b/source/backend/render/tracetask.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,47 +33,62 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/render/tracetask.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include -#include +// Boost header files #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/render/tracetask.h" +// POV-Ray header files (base module) +#include "base/image/colourspace.h" +#ifdef PROFILE_INTERSECTIONS +#include "base/image/image_fwd.h" +#endif +// POV-Ray header files (core module) #include "core/material/normal.h" #include "core/math/chi2.h" #include "core/math/jitter.h" #include "core/math/matrix.h" #include "core/render/trace.h" +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (backend module) #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" #include "backend/scene/viewthreaddata.h" -#ifdef PROFILE_INTERSECTIONS -#include "base/image/image.h" -#endif - // this must be the last file included #include "base/povdebug.h" namespace pov { +using std::min; +using std::max; +using std::vector; + #ifdef PROFILE_INTERSECTIONS bool gDoneBSP; bool gDoneBVH; POV_ULONG gMinVal = std::numeric_limits::max(); POV_ULONG gMaxVal = 0; POV_ULONG gIntersectionTime; - vector > gBSPIntersectionTimes; - vector > gBVHIntersectionTimes; - vector > *gIntersectionTimes; + vector> gBSPIntersectionTimes; + vector> gBVHIntersectionTimes; + vector> *gIntersectionTimes; #endif -class SmartBlock +class SmartBlock final { public: SmartBlock(int ox, int oy, int bw, int bh); @@ -330,9 +345,9 @@ void TraceTask::Finish() if (width == gBVHIntersectionTimes[0].size() && height == gBVHIntersectionTimes.size()) { SNGL scale = 1.0 / (gMaxVal - gMinVal); - Image::WriteOptions opts; + ImageWriteOptions opts; opts.bitsPerChannel = 16; - Image *img = Image::Create(width, height, Image::Gray_Int16, false); + Image *img = Image::Create(width, height, ImageDataType::Gray_Int16, false); for (int y = 0 ; y < height ; y++) for (int x = 0 ; x < width ; x++) img->SetGrayValue(x, y, (gBSPIntersectionTimes[y][x] - gMinVal) * scale); @@ -341,7 +356,7 @@ void TraceTask::Finish() delete imagefile; delete img; - img = Image::Create(width, height, Image::Gray_Int16, false); + img = Image::Create(width, height, ImageDataType::Gray_Int16, false); imagefile = NewOStream("bvhprofile.png", 0, false); for (int y = 0 ; y < height ; y++) for (int x = 0 ; x < width ; x++) @@ -350,7 +365,7 @@ void TraceTask::Finish() delete imagefile; delete img; - img = Image::Create(width, height, Image::Gray_Int16, false); + img = Image::Create(width, height, ImageDataType::Gray_Int16, false); imagefile = NewOStream("summedprofile.png", 0, false); for (int y = 0 ; y < height ; y++) for (int x = 0 ; x < width ; x++) @@ -359,7 +374,7 @@ void TraceTask::Finish() delete imagefile; delete img; - img = Image::Create(width, height, Image::RGBFT_Float, false); + img = Image::Create(width, height, ImageDataType::RGBFT_Float, false); imagefile = NewOStream("rgbprofile.png", 0, false); for (int y = 0 ; y < height ; y++) { @@ -1061,3 +1076,4 @@ void TraceTask::SubdivideOnePixel(DBL x, DBL y, DBL d, size_t bx, size_t by, siz } } +// end of namespace pov diff --git a/source/backend/render/tracetask.h b/source/backend/render/tracetask.h index 230f3542a..462b9a1d9 100644 --- a/source/backend/render/tracetask.h +++ b/source/backend/render/tracetask.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,15 +36,24 @@ #ifndef POVRAY_BACKEND_TRACETASK_H #define POVRAY_BACKEND_TRACETASK_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include "base/image/colourspace.h" +// POV-Ray header files (base module) +#include "base/image/colourspace_fwd.h" +// POV-Ray header files (core module) #include "core/lighting/radiosity.h" #include "core/material/media.h" #include "core/render/tracepixel.h" -#include "backend/frame.h" +// POV-Ray header files (backend module) #include "backend/render/rendertask.h" namespace pov @@ -53,33 +62,33 @@ namespace pov #ifdef PROFILE_INTERSECTIONS // NB not thread-safe (and not intended to be) extern POV_ULONG gIntersectionTime; - extern vector > gBSPIntersectionTimes; - extern vector > gBVHIntersectionTimes; - extern vector > *gIntersectionTimes; + extern std::vector> gBSPIntersectionTimes; + extern std::vector> gBVHIntersectionTimes; + extern std::vector> *gIntersectionTimes; #endif -class TraceTask : public RenderTask +class TraceTask final : public RenderTask { public: TraceTask(ViewData *vd, unsigned int tm, DBL js, DBL aat, DBL aac, unsigned int aad, pov_base::GammaCurvePtr& aag, unsigned int ps, bool psc, bool contributesToImage, bool hr, size_t seed); - virtual ~TraceTask(); + virtual ~TraceTask() override; - virtual void Run(); - virtual void Stopped(); - virtual void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; - class SubdivisionBuffer + class SubdivisionBuffer final { public: SubdivisionBuffer(size_t s); @@ -91,8 +100,8 @@ class TraceTask : public RenderTask void Clear(); private: - vector colors; - vector sampled; + std::vector colors; + std::vector sampled; size_t size; }; @@ -128,5 +137,6 @@ class TraceTask : public RenderTask }; } +// end of namespace pov #endif // POVRAY_BACKEND_TRACETASK_H diff --git a/source/backend/scene/backendscenedata.cpp b/source/backend/scene/backendscenedata.cpp index e5e2a0c45..e2829156a 100644 --- a/source/backend/scene/backendscenedata.cpp +++ b/source/backend/scene/backendscenedata.cpp @@ -33,19 +33,35 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/scene/backendscenedata.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include +// Boost header files #include #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/scene/backendscenedata.h" - +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/fileutil.h" +#include "base/path.h" +#include "base/stringutilities.h" + +// POV-Ray header files (core module) +// (none at the moment) +// POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (backend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -58,7 +74,7 @@ BackendSceneData::BackendSceneData() : UCS2String BackendSceneData::FindFile(POVMSContext ctx, const UCS2String& filename, unsigned int stype) { - vector filenames; + std::vector filenames; UCS2String foundfile; bool tryExactFirst; @@ -100,7 +116,7 @@ UCS2String BackendSceneData::FindFile(POVMSContext ctx, const UCS2String& filena #ifdef USE_SCENE_FILE_MAPPING // see if the file is available locally - for(vector::const_iterator i(filenames.begin()); i != filenames.end(); i++) + for(std::vector::const_iterator i(filenames.begin()); i != filenames.end(); i++) { FilenameToFilenameMap::iterator ilocalfile(scene2LocalFiles.find(*i)); @@ -109,7 +125,7 @@ UCS2String BackendSceneData::FindFile(POVMSContext ctx, const UCS2String& filena } // see if the file is available as temporary file - for(vector::const_iterator i(filenames.begin()); i != filenames.end(); i++) + for(std::vector::const_iterator i(filenames.begin()); i != filenames.end(); i++) { FilenameToFilenameMap::iterator itempfile(scene2TempFiles.find(*i)); @@ -309,3 +325,4 @@ OStream *BackendSceneData::CreateFile(POVMSContext ctx, const UCS2String& filena } } +// end of namespace pov diff --git a/source/backend/scene/backendscenedata.h b/source/backend/scene/backendscenedata.h index bd347326b..5c73a99ff 100644 --- a/source/backend/scene/backendscenedata.h +++ b/source/backend/scene/backendscenedata.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,14 +36,29 @@ #ifndef POVRAY_BACKEND_BACKENDSCENEDATA_H #define POVRAY_BACKEND_BACKENDSCENEDATA_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/scene/backendscenedata_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/stringtypes.h" + +// POV-Ray header files (core module) #include "core/scene/scenedata.h" +// POV-Ray header files (backend module) #include "backend/control/renderbackend.h" namespace pov { -class BackendSceneData : public SceneData +class BackendSceneData final : public SceneData { // Scene needs access to the private scene data constructor! friend class Scene; @@ -130,13 +145,11 @@ class BackendSceneData : public SceneData */ BackendSceneData(); - /// not available - BackendSceneData(const BackendSceneData&); - - /// not available - BackendSceneData& operator=(const BackendSceneData&); + BackendSceneData(const BackendSceneData&) = delete; + BackendSceneData& operator=(const BackendSceneData&) = delete; }; } +// end of namespace pov #endif // POVRAY_BACKEND_BACKENDSCENEDATA_H diff --git a/source/backend/scene/backendscenedata_fwd.h b/source/backend/scene/backendscenedata_fwd.h new file mode 100644 index 000000000..782d233f0 --- /dev/null +++ b/source/backend/scene/backendscenedata_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file backend/scene/backendscenedata_fwd.h +/// +/// Forward declarations related to ... what? +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BACKEND_BACKENDSCENEDATA_FWD_H +#define POVRAY_BACKEND_BACKENDSCENEDATA_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class BackendSceneData; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_BACKENDSCENEDATA_FWD_H diff --git a/source/backend/scene/view.cpp b/source/backend/scene/view.cpp index 00c60f63e..f1b693085 100644 --- a/source/backend/scene/view.cpp +++ b/source/backend/scene/view.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,27 +33,40 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/scene/view.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// Boost header files #include #include #include #include #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/scene/view.h" - +// POV-Ray header files (base module) #include "base/path.h" +#include "base/povassert.h" #include "base/timer.h" +#include "base/image/colourspace.h" +// POV-Ray header files (core module) #include "core/lighting/photons.h" #include "core/lighting/radiosity.h" #include "core/math/matrix.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" #include "povms/povmsid.h" +// POV-Ray header files (backend module) +#include "backend/control/messagefactory.h" #include "backend/control/renderbackend.h" #include "backend/lighting/photonestimationtask.h" #include "backend/lighting/photonshootingstrategy.h" @@ -73,6 +86,11 @@ namespace pov { +using std::min; +using std::max; +using std::shared_ptr; +using std::vector; + /// Round up to a power of two. inline unsigned int MakePowerOfTwo(unsigned int i) { @@ -1327,7 +1345,7 @@ void View::GetStatistics(POVMS_Object& renderStats) renderStats.SetLong(kPOVAttrib_GatherPerformedCnt, stats[Gather_Performed_Count]); renderStats.SetLong(kPOVAttrib_GatherExpandedCnt, stats[Gather_Expanded_Count]); - struct TimeData + struct TimeData final { POV_LONG cpuTime; POV_LONG realTime; @@ -1547,3 +1565,4 @@ const Camera *RTRData::CompletedFrame() } } +// end of namespace pov diff --git a/source/backend/scene/view.h b/source/backend/scene/view.h index abdf2f855..c5fb4164c 100644 --- a/source/backend/scene/view.h +++ b/source/backend/scene/view.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,12 +36,29 @@ #ifndef POVRAY_BACKEND_VIEW_H #define POVRAY_BACKEND_VIEW_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/scene/view_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +// POV-Ray header files (base module) +#include "base/types.h" // TODO - only appears to be pulled in for POVRect - can we avoid this? + +// POV-Ray header files (core module) +#include "core/core_fwd.h" #include "core/bounding/bsptree.h" #include "core/lighting/radiosity.h" #include "core/scene/camera.h" +// POV-Ray header files (backend module) +#include "backend/control/scene_fwd.h" +#include "backend/scene/viewthreaddata_fwd.h" #include "backend/support/taskqueue.h" namespace pov @@ -49,12 +66,7 @@ namespace pov using namespace pov_base; -class Scene; -class SceneData; -class ViewData; -class ViewThreadData; - -class RTRData +class RTRData final { public: RTRData(ViewData& v, int mrt); @@ -65,7 +77,7 @@ class RTRData /// number of frames rendered in real-time raytracing mode unsigned int numRTRframes; /// this holds the pixels rendered in real-time-raytracing mode - vector rtrPixels; + std::vector rtrPixels; /// the number of render threads to wait for int numRenderThreads; /// the number of render threads that have completed the current RTR frame @@ -89,7 +101,7 @@ class RTRData * such there are no public members but only accessor * methods. Please do not add public data members!!! */ -class ViewData +class ViewData final { // View needs access to the private view data constructor as well // as some private data in order to initialise it properly! @@ -105,7 +117,7 @@ class ViewData class BlockInfo { public: - virtual ~BlockInfo() {} // need to have a virtual member so we can use dynamic_cast + virtual ~BlockInfo() {} }; /** @@ -152,7 +164,7 @@ class ViewData * data passed to whichever rendering thread the rectangle will be re-dispatched to. * If this value is `nullptr`, the rectangle will not be re-dispatched. */ - void CompletedRectangle(const POVRect& rect, unsigned int serial, const vector& pixels, + void CompletedRectangle(const POVRect& rect, unsigned int serial, const std::vector& pixels, unsigned int size, bool relevant, bool complete, float completion = 1.0, BlockInfo* blockInfo = nullptr); @@ -173,8 +185,8 @@ class ViewData * data passed to whichever rendering thread the rectangle will be re-dispatched to. * If this value is `nullptr`, the rectangle will not be re-dispatched. */ - void CompletedRectangle(const POVRect& rect, unsigned int serial, const vector& positions, - const vector& colors, unsigned int size, bool relevant, bool complete, + void CompletedRectangle(const POVRect& rect, unsigned int serial, const std::vector& positions, + const std::vector& colors, unsigned int size, bool relevant, bool complete, float completion = 1.0, BlockInfo* blockInfo = nullptr); /** @@ -226,7 +238,7 @@ class ViewData * Get the scene data for this view. * @return Scene data. */ - inline shared_ptr& GetSceneData() { return sceneData; } + inline std::shared_ptr& GetSceneData() { return sceneData; } /** * Get the view id for this view. @@ -247,7 +259,7 @@ class ViewData void SetHighestTraceLevel(unsigned int htl); /** - * Get the render qualitiy features to use when rendering this view. + * Get the render quality features to use when rendering this view. * @return Quality feature flags. */ const QualityFlags& GetQualityFeatureFlags() const; @@ -272,7 +284,8 @@ class ViewData private: - struct BlockPostponedEntry { + struct BlockPostponedEntry final + { unsigned int blockId; unsigned int pass; BlockPostponedEntry(unsigned int id, unsigned int p) : blockId(id), pass(p) {} @@ -317,7 +330,7 @@ class ViewData /// list of blocks postponed for some reason BlockIdSet blockPostponedList; /// list of additional block information - vector blockInfoList; + std::vector blockInfoList; /// area of view to be rendered POVRect renderArea; /// camera of this view @@ -325,7 +338,7 @@ class ViewData /// generated radiosity data RadiosityCache radiosityCache; /// scene data - shared_ptr sceneData; + std::shared_ptr sceneData; /// view id RenderBackend::ViewId viewId; @@ -349,7 +362,7 @@ class ViewData * Create view data. * @param sd Scene data associated with the view data. */ - ViewData(shared_ptr sd); + ViewData(std::shared_ptr sd); /** * Destructor. @@ -361,7 +374,7 @@ class ViewData * View class representing an view with a specific camera * being rendered. */ -class View +class View final { // Scene needs access to the private view constructor! friend class Scene; @@ -440,7 +453,7 @@ class View /// running and pending render tasks for this view TaskQueue renderTasks; /// view thread data (i.e. statistics) - vector viewThreadData; + std::vector viewThreadData; /// view data ViewData viewData; /// stop request flag @@ -450,11 +463,8 @@ class View /// BSP tree mailbox BSPTree::Mailbox mailbox; - /// not available - View(); - - /// not available - View(const View&); + View() = delete; + View(const View&) = delete; /** * Create an view and associate a scene's data with it. @@ -464,10 +474,9 @@ class View * @param vid Id of this view to include with * POVMS messages sent to the frontend. */ - explicit View(shared_ptr sd, unsigned int width, unsigned int height, RenderBackend::ViewId vid); + explicit View(std::shared_ptr sd, unsigned int width, unsigned int height, RenderBackend::ViewId vid); - /// not available - View& operator=(const View&); + View& operator=(const View&) = delete; /** * Dispatch any shutdown messages appropriate at the end of rendering a view (e.g. max_gradient). @@ -488,7 +497,7 @@ class View * @param bsl Block serial numbers to skip. * @param fs First block to start with checking with serial number. */ - void SetNextRectangle(TaskQueue& taskq, shared_ptr bsl, unsigned int fs); + void SetNextRectangle(TaskQueue& taskq, std::shared_ptr bsl, unsigned int fs); /** * Thread controlling the render task queue. @@ -505,5 +514,6 @@ class View }; } +// end of namespace pov #endif // POVRAY_BACKEND_VIEW_H diff --git a/source/backend/scene/view_fwd.h b/source/backend/scene/view_fwd.h new file mode 100644 index 000000000..de4fefdc8 --- /dev/null +++ b/source/backend/scene/view_fwd.h @@ -0,0 +1,52 @@ +//****************************************************************************** +/// +/// @file backend/scene/view_fwd.h +/// +/// Forward declarations related to ... what? +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BACKEND_VIEW_FWD_H +#define POVRAY_BACKEND_VIEW_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class View; +class ViewData; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_VIEW_FWD_H diff --git a/source/backend/scene/viewthreaddata.cpp b/source/backend/scene/viewthreaddata.cpp index 82020a62c..3044f6acc 100644 --- a/source/backend/scene/viewthreaddata.cpp +++ b/source/backend/scene/viewthreaddata.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,12 +33,22 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/scene/viewthreaddata.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/scene/viewthreaddata.h" +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// POV-Ray header files (POVMS module) +// (none at the moment) +// POV-Ray header files (backend module) #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" @@ -49,7 +59,7 @@ namespace pov { ViewThreadData::ViewThreadData(ViewData *vd, size_t seed) : - TraceThreadData(dynamic_pointer_cast(vd->GetSceneData()), seed), + TraceThreadData(std::dynamic_pointer_cast(vd->GetSceneData()), seed), viewData(vd) { } @@ -74,3 +84,4 @@ const POVRect& ViewThreadData::GetRenderArea() } } +// end of namespace pov diff --git a/source/backend/scene/viewthreaddata.h b/source/backend/scene/viewthreaddata.h index 3817f7d62..66e3ab697 100644 --- a/source/backend/scene/viewthreaddata.h +++ b/source/backend/scene/viewthreaddata.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,17 +36,30 @@ #ifndef POVRAY_BACKEND_VIEWTHREADDATA_H #define POVRAY_BACKEND_VIEWTHREADDATA_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/scene/viewthreaddata_fwd.h" + +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/tracethreaddata.h" +// POV-Ray header files (backend module) +#include "backend/scene/view_fwd.h" + namespace pov { -class ViewData; - /** * Class holding render thread specific data. */ -class ViewThreadData : public TraceThreadData +class ViewThreadData final : public TraceThreadData { friend class Scene; public: @@ -80,21 +93,19 @@ class ViewThreadData : public TraceThreadData /// view data ViewData *viewData; private: - /// not available - ViewThreadData(); - /// not available - ViewThreadData(const ViewThreadData&); + ViewThreadData() = delete; + ViewThreadData(const ViewThreadData&) = delete; + ViewThreadData& operator=(const ViewThreadData&) = delete; - /// not available - ViewThreadData& operator=(const ViewThreadData&); public: // TODO FIXME - temporary workaround [trf] /** * Destructor. */ - ~ViewThreadData(); + virtual ~ViewThreadData() override; }; } +// end of namespace pov #endif // POVRAY_BACKEND_VIEWTHREADDATA_H diff --git a/source/backend/scene/viewthreaddata_fwd.h b/source/backend/scene/viewthreaddata_fwd.h new file mode 100644 index 000000000..df2b7b37e --- /dev/null +++ b/source/backend/scene/viewthreaddata_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file backend/scene/viewthreaddata_fwd.h +/// +/// Forward declarations related to ... what? +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BACKEND_VIEWTHREADDATA_FWD_H +#define POVRAY_BACKEND_VIEWTHREADDATA_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class ViewThreadData; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_VIEWTHREADDATA_FWD_H diff --git a/source/backend/support/task.cpp b/source/backend/support/task.cpp index c5f01a6bf..f6732d71a 100644 --- a/source/backend/support/task.cpp +++ b/source/backend/support/task.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,19 +33,29 @@ /// //****************************************************************************** -#include +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/support/task.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// Boost header files #include #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/support/task.h" - +// POV-Ray header files (base module) +#include "base/povassert.h" #include "base/timer.h" #include "base/types.h" +// POV-Ray header files (core module) +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (backend module) #include "backend/control/messagefactory.h" #include "backend/scene/backendscenedata.h" @@ -270,9 +280,15 @@ void Task::Cleanup () #endif // POV_USE_DEFAULT_TASK_CLEANUP -SceneTask::SceneTask(ThreadData *td, const boost::function1& f, const char* sn, shared_ptr sd, RenderBackend::ViewId vid) : +SceneTask::SceneTask(ThreadData *td, const boost::function1& f, const char* sn, std::shared_ptr sd, RenderBackend::ViewId vid) : Task(td, f), - messageFactory(sd->warningLevel, sn, sd->backendAddress, sd->frontendAddress, sd->sceneId, vid) + mpMessageFactory(new MessageFactory(sd->warningLevel, sn, sd->backendAddress, sd->frontendAddress, sd->sceneId, vid)) {} +SceneTask::~SceneTask() +{ + delete mpMessageFactory; +} + } +// end of namespace pov diff --git a/source/backend/support/task.h b/source/backend/support/task.h index dfb91da0e..14a2f6904 100644 --- a/source/backend/support/task.h +++ b/source/backend/support/task.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,26 +36,34 @@ #ifndef POVRAY_BACKEND_TASK_H #define POVRAY_BACKEND_TASK_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include -#include +// Boost header files #include #include -#include "backend/frame.h" +// POV-Ray header files (base module) +#include "base/base_fwd.h" +#include "base/timer.h" -#include "backend/control/messagefactory.h" +// POV-Ray header files (backend module) +#include "backend/control/messagefactory_fwd.h" #include "backend/control/renderbackend.h" -#include "base/timer.h" +#include "backend/scene/backendscenedata_fwd.h" namespace pov { using namespace pov_base; -class BackendSceneData; - - class Task { public: @@ -119,7 +127,7 @@ class Task protected: - struct StopThreadException { }; + struct StopThreadException final {}; // TODO - consider subclassing from std::exception hierarchy. virtual void Run() = 0; virtual void Stopped() = 0; @@ -161,14 +169,9 @@ class Task inline void FatalErrorHandler(Exception& e) { fatalErrorHandler(e); } - /// not available - Task(); - - /// not available - Task(const Task&); - - /// not available - Task& operator=(const Task&); + Task() = delete; + Task(const Task&) = delete; + Task& operator=(const Task&) = delete; /// Execute the thread. void TaskThread(const boost::function0& completion); @@ -194,12 +197,14 @@ class Task class SceneTask : public Task { public: - SceneTask(ThreadData *td, const boost::function1& f, const char* sn, shared_ptr sd, RenderBackend::ViewId vid = 0); + SceneTask(ThreadData *td, const boost::function1& f, const char* sn, std::shared_ptr sd, RenderBackend::ViewId vid = 0); + virtual ~SceneTask() override; protected: - MessageFactory messageFactory; + MessageFactory* mpMessageFactory; }; } +// end of namespace pov #endif // POVRAY_BACKEND_TASK_H diff --git a/source/backend/support/taskqueue.cpp b/source/backend/support/taskqueue.cpp index 2a8fe6e14..9db706040 100644 --- a/source/backend/support/taskqueue.cpp +++ b/source/backend/support/taskqueue.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,13 +33,22 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/support/taskqueue.h" + +// C++ variants of C standard header files +// C++ standard header files + +// Boost header files #include #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/support/taskqueue.h" +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// POV-Ray header files (POVMS module) +// (none at the moment) +// POV-Ray header files (backend module) #include "backend/support/task.h" // this must be the last file included @@ -48,7 +57,8 @@ namespace pov { -using boost::recursive_mutex; +using std::list; +using std::shared_ptr; TaskQueue::TaskQueue() : failed(kNoError) { @@ -61,7 +71,7 @@ TaskQueue::~TaskQueue() void TaskQueue::Stop() { - recursive_mutex::scoped_lock lock(queueMutex); + boost::recursive_mutex::scoped_lock lock(queueMutex); // we pass through this list twice; the first time through only sets the cancel // flag, and the second time through waits for the threads to exit. if we only @@ -83,7 +93,7 @@ void TaskQueue::Stop() void TaskQueue::Pause() { - recursive_mutex::scoped_lock lock(queueMutex); + boost::recursive_mutex::scoped_lock lock(queueMutex); for(list::iterator i(activeTasks.begin()); i != activeTasks.end(); i++) i->GetTask()->Pause(); @@ -142,7 +152,7 @@ bool TaskQueue::Failed() int TaskQueue::FailureCode(int defval) { - recursive_mutex::scoped_lock lock(queueMutex); + boost::recursive_mutex::scoped_lock lock(queueMutex); if(failed == kNoError) return defval; @@ -261,3 +271,4 @@ void TaskQueue::Notify() } } +// end of namespace pov diff --git a/source/backend/support/taskqueue.h b/source/backend/support/taskqueue.h index cb9e2b664..ba482a311 100644 --- a/source/backend/support/taskqueue.h +++ b/source/backend/support/taskqueue.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,19 +36,36 @@ #ifndef POVRAY_BACKEND_TASKQUEUE_H #define POVRAY_BACKEND_TASKQUEUE_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include +#include + +// Boost header files #include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (backend module) #include "backend/support/task.h" namespace pov { -class TaskQueue +class TaskQueue final { - class TaskEntry + class TaskEntry final { public: enum EntryType @@ -60,19 +77,19 @@ class TaskQueue }; TaskEntry(EntryType et) : entryType(et) { } - TaskEntry(shared_ptr rt) : entryType(kTask), task(rt) { } + TaskEntry(std::shared_ptr rt) : entryType(kTask), task(rt) { } TaskEntry(POVMS_Message& m) : entryType(kMessage), msg(m) { } TaskEntry(const boost::function1& f) : entryType(kFunction), fn(f) { } ~TaskEntry() { } - shared_ptr GetTask() { return task; } + std::shared_ptr GetTask() { return task; } POVMS_Message& GetMessage() { return msg; } boost::function1& GetFunction() { return fn; } EntryType GetEntryType() { return entryType; } private: EntryType entryType; - shared_ptr task; + std::shared_ptr task; POVMS_Message msg; boost::function1 fn; }; @@ -103,20 +120,19 @@ class TaskQueue /// queued task list std::queue queuedTasks; /// active task list - list activeTasks; + std::list activeTasks; /// queue mutex boost::recursive_mutex queueMutex; /// failed code int failed; /// wait for data in queue or related operation to be processed boost::condition processCondition; - /// not available - TaskQueue(const TaskQueue&); - /// not available - TaskQueue& operator=(const TaskQueue&); + TaskQueue(const TaskQueue&) = delete; + TaskQueue& operator=(const TaskQueue&) = delete; }; } +// end of namespace pov #endif // POVRAY_BACKEND_TASKQUEUE_H diff --git a/source/base/animation/animation.cpp b/source/base/animation/animation.cpp index 22af697b0..3ebcd1c5c 100644 --- a/source/base/animation/animation.cpp +++ b/source/base/animation/animation.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,14 +36,21 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/animation/animation.h" -// Boost header files -#include +// C++ variants of C standard header files +// (none at the moment) -// POV-Ray base header files +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/povassert.h" //#include "base/animation/avi.h" #include "base/animation/moov.h" //#include "base/animation/mpeg.h" #include "base/image/bmp.h" +#include "base/image/colourspace.h" +#include "base/image/image.h" #include "base/image/jpeg_pov.h" #include "base/image/png_pov.h" @@ -191,7 +198,7 @@ void Animation::AppendFrame(Image *image) // writing only - NOTE: This method re { if(writeOptions.blurradius > 0.0f) { - boost::scoped_ptr mask(Image::Create(image->GetWidth(), image->GetHeight(), Image::Bit_Map)); + std::unique_ptr mask(Image::Create(image->GetWidth(), image->GetHeight(), ImageDataType::Bit_Map)); float r, g, b, f, t; mask->FillBitValue(false); @@ -245,7 +252,7 @@ void Animation::SetCurrentFrame(unsigned int frame) // reading only currentFrame = frame; } -const vector& Animation::GetWarnings() const +const std::vector& Animation::GetWarnings() const { return warnings; } @@ -259,11 +266,11 @@ Image *Animation::ReadFrame(IStream *file) { POV_OFF_T bytes = 0; Image *image = nullptr; - Image::ReadOptions options; + ImageReadOptions options; options.defaultGamma = PowerLawGammaCurve::GetByDecodingGamma(readOptions.gamma); options.gammacorrect = readOptions.gammacorrect; - options.itype = Image::RGBFT_Float; + options.itype = ImageDataType::RGBFT_Float; switch(fileType) { @@ -328,10 +335,10 @@ Image *Animation::ReadFrame(IStream *file) POV_OFF_T Animation::WriteFrame(OStream *file, const Image *image) { - Image::WriteOptions options; + ImageWriteOptions options; options.bitsPerChannel = writeOptions.bpcc; - options.alphaMode = (writeOptions.alphachannel ? Image::kAlphaMode_Default : Image::kAlphaMode_None); + options.alphaMode = (writeOptions.alphachannel ? ImageAlphaMode::Default : ImageAlphaMode::None); options.compression = writeOptions.compress; // options.gamma = writeOptions.gamma; options.encodingGamma = PowerLawGammaCurve::GetByEncodingGamma(writeOptions.gamma); @@ -432,3 +439,4 @@ void Animation::GetBlurredPixel(const Image& image, unsigned int x, unsigned int } } +// end of namespace pov_base diff --git a/source/base/animation/animation.h b/source/base/animation/animation.h index 3252a0add..5b7fdd9f6 100644 --- a/source/base/animation/animation.h +++ b/source/base/animation/animation.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,14 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include -// POV-Ray base header files -#include "base/fileinputoutput.h" +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" #include "base/pov_err.h" -#include "base/types.h" -#include "base/image/image.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -94,7 +97,7 @@ class Animation YUV410 }; - struct ReadOptions + struct ReadOptions final { float gamma; bool gammacorrect; @@ -102,7 +105,7 @@ class Animation ReadOptions() : gamma(1.0f), gammacorrect(false) { } }; - struct WriteOptions + struct WriteOptions final { ColorEncodingType colorencoding; unsigned char compress; // relative quality from 100 best to 0 worst @@ -134,7 +137,7 @@ class Animation unsigned int GetWidth() const { return width; } unsigned int GetHeight() const { return height; } - const vector& GetWarnings() const; + const std::vector& GetWarnings() const; void ClearWarnings(); protected: FileType fileType; @@ -144,7 +147,7 @@ class Animation unsigned int height; ReadOptions readOptions; WriteOptions writeOptions; - vector warnings; + std::vector warnings; CodecType codec; unsigned int currentFrame; unsigned int totalFrames; @@ -163,12 +166,9 @@ class Animation float blurMatrix[16][16]; // only uses 15 x 15 maximum (16 x 16 for better alignment) int blurMatrixRadius; - /// not available - Animation(); - /// not available - Animation(const Animation&); - /// not available - Animation& operator=(Animation&); + Animation() = delete; + Animation(const Animation&) = delete; + Animation& operator=(Animation&) = delete; }; /// @} @@ -176,5 +176,6 @@ class Animation //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_ANIMATION_H diff --git a/source/base/animation/moov.cpp b/source/base/animation/moov.cpp index ab025dfd1..80d8fee88 100644 --- a/source/base/animation/moov.cpp +++ b/source/base/animation/moov.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,7 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/animation/moov.h" -// POV-Ray base header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/pov_err.h" #include "base/types.h" #include "base/animation/animation.h" @@ -49,7 +56,7 @@ namespace pov_base typedef POV_INT32 Type; // TODO - this is a lousy type name -struct PrivateData +struct PrivateData final { unsigned int width; unsigned int height; @@ -58,7 +65,7 @@ struct PrivateData int timescale; int frameduration; POV_OFF_T mdatsize; - vector imagesizes; + std::vector imagesizes; }; namespace Moov @@ -71,25 +78,25 @@ void WriteInt4(OStream *file, POV_INT32 data); void WriteInt8(OStream *file, POV_INT64 data); void WriteN(OStream *file, size_t cnt, POV_INT8 data); -void *ReadFileHeader(IStream *file, float& lengthinseconds, unsigned int& lengthinframes, Animation::CodecType& codec, unsigned int& w, unsigned int& h, const Animation::ReadOptions& options, vector& warnings) +void *ReadFileHeader(IStream *file, float& lengthinseconds, unsigned int& lengthinframes, Animation::CodecType& codec, unsigned int& w, unsigned int& h, const Animation::ReadOptions& options, std::vector& warnings) { throw POV_EXCEPTION(kCannotHandleDataErr, "Reading QuickTime movie files is not supported (yet)!"); return nullptr; } -void PreReadFrame(IStream *file, unsigned int frame, POV_OFF_T& bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, vector& warnings, void *state) +void PreReadFrame(IStream *file, unsigned int frame, POV_OFF_T& bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, std::vector& warnings, void *state) { } -void PostReadFrame(IStream *file, unsigned int frame, POV_OFF_T bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, vector& warnings, void *state) +void PostReadFrame(IStream *file, unsigned int frame, POV_OFF_T bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, std::vector& warnings, void *state) { } -void FinishReadFile(IStream *file, vector& warnings, void *state) +void FinishReadFile(IStream *file, std::vector& warnings, void *state) { } -void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w, unsigned int h, const Animation::WriteOptions& options, vector& warnings) +void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w, unsigned int h, const Animation::WriteOptions& options, std::vector& warnings) { PrivateData pd; @@ -135,7 +142,7 @@ void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w break; } - pd.timescale = max(int(double(options.framespersecond) * double(m)), 1); + pd.timescale = std::max(int(double(options.framespersecond) * double(m)), 1); // frame duration according to time scale @@ -153,7 +160,7 @@ void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w return reinterpret_cast(new PrivateData(pd)); } -void PreWriteFrame(OStream *, const Animation::WriteOptions&, vector&, void *state) +void PreWriteFrame(OStream *, const Animation::WriteOptions&, std::vector&, void *state) { PrivateData *pd = reinterpret_cast(state); @@ -163,7 +170,7 @@ void PreWriteFrame(OStream *, const Animation::WriteOptions&, vector&, v // there really is nothing to do here [trf] } -void PostWriteFrame(OStream *file, POV_OFF_T bytes, const Animation::WriteOptions&, vector&, void *state) +void PostWriteFrame(OStream *file, POV_OFF_T bytes, const Animation::WriteOptions&, std::vector&, void *state) { PrivateData *pd = reinterpret_cast(state); @@ -184,7 +191,7 @@ void PostWriteFrame(OStream *file, POV_OFF_T bytes, const Animation::WriteOption pd->imagesizes.push_back(int(bytes)); } -void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, vector& warnings, void *state) +void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, std::vector& warnings, void *state) { PrivateData *pd = reinterpret_cast(state); @@ -372,7 +379,7 @@ void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, vect WriteInt4(file, 0); // sample size (all samples have different sizes, so this needs to be zero) WriteInt4(file, pd->imagesizes.size()); // number of entries - for(vector::const_iterator i = pd->imagesizes.begin(); i != pd->imagesizes.end(); i++) + for(std::vector::const_iterator i = pd->imagesizes.begin(); i != pd->imagesizes.end(); i++) WriteInt4(file, *i); // sample size entry delete pd; @@ -463,5 +470,7 @@ void WriteN(OStream *file, size_t cnt, POV_INT8 data) } } +// end of namespace Moov } +// end of namespace pov_base diff --git a/source/base/animation/moov.h b/source/base/animation/moov.h index 4b2366039..48c4295f2 100644 --- a/source/base/animation/moov.h +++ b/source/base/animation/moov.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/types.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" #include "base/animation/animation.h" namespace pov_base @@ -55,22 +62,24 @@ namespace pov_base namespace Moov { -void *ReadFileHeader(IStream *file, float& lengthinseconds, unsigned int& lengthinframes, Animation::CodecType& codec, unsigned int& w, unsigned int& h, const Animation::ReadOptions& options, vector& warnings); -void PreReadFrame(IStream *file, unsigned int frame, POV_OFF_T& bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, vector& warnings, void *state); -void PostReadFrame(IStream *file, unsigned int frame, POV_OFF_T bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, vector& warnings, void *state); -void FinishReadFile(IStream *file, vector& warnings, void *state); +void *ReadFileHeader(IStream *file, float& lengthinseconds, unsigned int& lengthinframes, Animation::CodecType& codec, unsigned int& w, unsigned int& h, const Animation::ReadOptions& options, std::vector& warnings); +void PreReadFrame(IStream *file, unsigned int frame, POV_OFF_T& bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, std::vector& warnings, void *state); +void PostReadFrame(IStream *file, unsigned int frame, POV_OFF_T bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, std::vector& warnings, void *state); +void FinishReadFile(IStream *file, std::vector& warnings, void *state); -void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w, unsigned int h, const Animation::WriteOptions& options, vector& warnings); -void PreWriteFrame(OStream *file, const Animation::WriteOptions& options, vector& warnings, void *state); -void PostWriteFrame(OStream *file, POV_OFF_T bytes, const Animation::WriteOptions& options, vector& warnings, void *state); -void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, vector& warnings, void *state); +void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w, unsigned int h, const Animation::WriteOptions& options, std::vector& warnings); +void PreWriteFrame(OStream *file, const Animation::WriteOptions& options, std::vector& warnings, void *state); +void PostWriteFrame(OStream *file, POV_OFF_T bytes, const Animation::WriteOptions& options, std::vector& warnings, void *state); +void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, std::vector& warnings, void *state); } +// end of namespace Moov /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_MOOV_H diff --git a/source/base/base_fwd.h b/source/base/base_fwd.h new file mode 100644 index 000000000..c71b98949 --- /dev/null +++ b/source/base/base_fwd.h @@ -0,0 +1,59 @@ +//****************************************************************************** +/// +/// @file base/base_fwd.h +/// +/// Forward declaration of base types referenced by other modules. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_FWD_H +#define POVRAY_BASE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class Exception; +class ThreadData; + +enum class CharsetID : int; +enum LegacyCharset : int; + +/// 5-dimensional vector type shared between parser and splines. +/// @todo Make this obsolete. +typedef double EXPRESS[5]; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_FWD_H diff --git a/source/base/colour.cpp b/source/base/colour.cpp index d29e5ca84..6d56151f8 100644 --- a/source/base/colour.cpp +++ b/source/base/colour.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,13 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/colour.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -62,3 +69,4 @@ template class GenericColour; template class GenericColour; } +// end of namespace pov_base diff --git a/source/base/colour.h b/source/base/colour.h index d226c48d4..d39324149 100644 --- a/source/base/colour.h +++ b/source/base/colour.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,15 +40,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include -// Standard C++ header files +// C++ standard header files +#include #include -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/base_fwd.h" #include "base/mathutil.h" -#include "base/types.h" #define NUM_COLOUR_CHANNELS 3 @@ -119,7 +120,7 @@ const PreciseColourChannel kBlueIntensity = 0.114; /// @tparam T Floating-point type to use for the individual colour components. /// template -class GenericRGBColour +class GenericRGBColour final { public: @@ -241,11 +242,11 @@ class GenericRGBColour /// @remark This used to be implemented differently at different places in the code; /// variations were: /// - `max3(r,g,b)` - /// - `max3(fabs(r),fabs(g),fabs(b))` - /// - `fabs(greyscale)` [1] - /// - `max(0.0,greyscale)` - /// @remark [1] A variant of this was `max(0.0,fabs(greyscale))`; note the superfluous - /// `max()`. + /// - `max3(std::fabs(r),std::fabs(g),std::fabs(b))` + /// - `std::fabs(greyscale)` [1] + /// - `std::max(0.0,greyscale)` + /// @remark [1] A variant of this was `std::max(0.0,std::fabs(greyscale))`; note the superfluous + /// `std::max()`. /// @remark The rationale for choosing the current implementation is as follows: /// - In general, the weight should scale proportionally with the colour /// brightness. [2] @@ -265,9 +266,9 @@ class GenericRGBColour /// @remark For backward compatibility, @ref WeightMax(), @ref WeightMaxAbs(), /// @ref WeightGreyscale() and @ref WeightAbsGreyscale() are provided. - return (fabs(mColour[RED]) + - fabs(mColour[GREEN]) + - fabs(mColour[BLUE])) / 3.0; + return (std::fabs(mColour[RED]) + + std::fabs(mColour[GREEN]) + + std::fabs(mColour[BLUE])) / 3.0; } /// Computes a measure for the weight of the colour based on the magnitude of its greyscale @@ -278,7 +279,7 @@ class GenericRGBColour /// inline T WeightAbsGreyscale() const { - return fabs(Greyscale()); + return std::fabs(Greyscale()); } /// Computes a measure for the weight of the colour based on its greyscale value. @@ -298,7 +299,7 @@ class GenericRGBColour /// greatest value. /// /// @note Do _not_ use this function if you absolutely want to know the intensity of - /// the strongest colour channel. For such cases, use @ref max() instead. + /// the strongest colour channel. For such cases, use @ref Max() instead. /// /// @deprecated Calls to this function should probably be replaced by calls to /// @ref WeightMaxAbs() or @ref Weight() for consistency of colour math. @@ -338,9 +339,9 @@ class GenericRGBColour /// inline T MaxAbs() const { - return max3(fabs(mColour[RED]), - fabs(mColour[GREEN]), - fabs(mColour[BLUE])); + return max3(std::fabs(mColour[RED]), + std::fabs(mColour[GREEN]), + std::fabs(mColour[BLUE])); } /// Computes the intensity of the colour channel with the smallest value. @@ -378,9 +379,9 @@ class GenericRGBColour inline bool IsNearZero(T epsilon) const { - return (fabs(mColour[RED]) < epsilon) && - (fabs(mColour[GREEN]) < epsilon) && - (fabs(mColour[BLUE]) < epsilon); + return (std::fabs(mColour[RED]) < epsilon) && + (std::fabs(mColour[GREEN]) < epsilon) && + (std::fabs(mColour[BLUE]) < epsilon); } inline void Clear() @@ -427,16 +428,16 @@ class GenericRGBColour inline GenericRGBColour ClippedUpper(T maxc) const { - return GenericRGBColour(min(mColour[RED], maxc), - min(mColour[GREEN], maxc), - min(mColour[BLUE], maxc)); + return GenericRGBColour(std::min(mColour[RED], maxc), + std::min(mColour[GREEN], maxc), + std::min(mColour[BLUE], maxc)); } inline GenericRGBColour ClippedLower(T minc) const { - return GenericRGBColour(max(mColour[RED], minc), - max(mColour[GREEN], minc), - max(mColour[BLUE], minc)); + return GenericRGBColour(std::max(mColour[RED], minc), + std::max(mColour[GREEN], minc), + std::max(mColour[BLUE], minc)); } inline GenericRGBColour operator+(const GenericRGBColour& b) const @@ -614,9 +615,9 @@ inline GenericRGBColour operator- (double a, const GenericRGBColour& b) { template inline T ColourDistance (const GenericRGBColour& a, const GenericRGBColour& b) { - return fabs(a.red() - b.red()) + - fabs(a.green() - b.green()) + - fabs(a.blue() - b.blue()); + return std::fabs(a.red() - b.red()) + + std::fabs(a.green() - b.green()) + + std::fabs(a.blue() - b.blue()); } /// @relates GenericRGBColour @@ -672,7 +673,7 @@ typedef GenericRGBColour PreciseRGBColour; ///< High pr /// @tparam T Floating-point type to use for the individual colour components. /// template -class GenericRGBFTColour +class GenericRGBFTColour final { public: @@ -681,8 +682,6 @@ class GenericRGBFTColour friend GenericRGBFTColour ToRGBFTColour(const GenericTransColour& col); - typedef DBL EXPRESS[5]; - /// Default constructor. inline GenericRGBFTColour() : mColour(0.0), @@ -966,7 +965,7 @@ inline GenericRGBFTColour operator- (double a, const GenericRGBFTColour& b template inline T ColourDistanceRGBT (const GenericRGBFTColour& a, const GenericRGBFTColour& b) { - return ColourDistance(a.rgb(), b.rgb()) + fabs(a.transm() - b.transm()); + return ColourDistance(a.rgb(), b.rgb()) + std::fabs(a.transm() - b.transm()); } typedef GenericRGBFTColour RGBFTColour; ///< Standard precision RGBFT colour. @@ -995,7 +994,7 @@ enum /// @tparam T Floating-point type to use for the individual colour components. /// template -class GenericRGBTColour +class GenericRGBTColour final { public: @@ -1069,7 +1068,7 @@ class GenericRGBTColour inline bool IsNearZero(T epsilon) const { return mColour.IsNearZero(epsilon) && - (fabs(mTransm) < epsilon); + (std::fabs(mTransm) < epsilon); } inline void Clear() @@ -1221,7 +1220,7 @@ inline GenericRGBTColour operator- (double a, const GenericRGBTColour& b) template inline T ColourDistanceRGBT (const GenericRGBTColour& a, const GenericRGBTColour& b) { - return ColourDistance(a.rgb(), b.rgb()) + fabs(a.transm() - b.transm()); + return ColourDistance(a.rgb(), b.rgb()) + std::fabs(a.transm() - b.transm()); } /// @relates GenericRGBTColour @@ -1245,7 +1244,7 @@ typedef GenericRGBTColour PreciseRGBTColour; ///< High pr /// @tparam T Floating-point type to use for the individual colour channels. /// template -class GenericColour +class GenericColour final { public: @@ -1384,11 +1383,11 @@ class GenericColour /// @remark This used to be implemented differently at different places in the code; /// variations were: /// - `max3(r,g,b)` - /// - `max3(fabs(r),fabs(g),fabs(b))` - /// - `fabs(greyscale)` [1] - /// - `max(0.0,greyscale)` - /// @remark [1] A variant of this was `max(0.0,fabs(greyscale))`; note the superfluous - /// `max()`. + /// - `max3(std::fabs(r),std::fabs(g),std::fabs(b))` + /// - `std::fabs(greyscale)` [1] + /// - `std::max(0.0,greyscale)` + /// @remark [1] A variant of this was `std::max(0.0,std::fabs(greyscale))`; note the superfluous + /// `std::max()`. /// @remark The rationale for choosing the current implementation is as follows: /// - In general, the weight should scale proportionally with the colour /// brightness. [2] @@ -1419,7 +1418,7 @@ class GenericColour /// inline T WeightAbsGreyscale() const { - return fabs(Greyscale()); + return std::fabs(Greyscale()); } /// Computes a measure for the weight of the colour based on its greyscale value. @@ -1439,7 +1438,7 @@ class GenericColour /// greatest value. /// /// @note Do _not_ use this function if you absolutely want to know the intensity of - /// the strongest colour channel. For such cases, use @ref max() instead. + /// the strongest colour channel. For such cases, use @ref Max() instead. /// /// @deprecated Calls to this function should probably be replaced by calls to /// @ref WeightMaxAbs() or @ref Weight() for consistency of colour math. @@ -1465,7 +1464,7 @@ class GenericColour { T result = 0.0; for (int i = 0; i < channels; i ++) - result += fabs(mColour[i]); + result += std::fabs(mColour[i]); return result; } @@ -1478,7 +1477,7 @@ class GenericColour { T result = mColour[0]; for (int i = 1; i < channels; i ++) - result = max(result, mColour[i]); + result = std::max(result, mColour[i]); return result; } @@ -1491,7 +1490,7 @@ class GenericColour { T result = mColour[0]; for (int i = 1; i < channels; i ++) - result = max(result, fabs(mColour[i])); + result = std::max(result, std::fabs(mColour[i])); return result; } @@ -1501,7 +1500,7 @@ class GenericColour { T result = mColour[0]; for (int i = 1; i < channels; i ++) - result = min(result, mColour[i]); + result = std::min(result, mColour[i]); return result; } @@ -1522,7 +1521,7 @@ class GenericColour { bool result = true; for (int i = 0; i < channels; i ++) - result = result && (fabs(mColour[i]) < epsilon); + result = result && (std::fabs(mColour[i]) < epsilon); return result; } @@ -1562,7 +1561,7 @@ class GenericColour { GenericColour result; for (int i = 0; i < channels; i ++) - result.mColour[i] = min(mColour[i], maxc); + result.mColour[i] = std::min(mColour[i], maxc); return result; } @@ -1570,7 +1569,7 @@ class GenericColour { GenericColour result; for (int i = 0; i < channels; i ++) - result.mColour[i] = max(mColour[i], minc); + result.mColour[i] = std::max(mColour[i], minc); return result; } @@ -1810,7 +1809,7 @@ extern template class GenericColour; /// @tparam T Floating-point type to use for the individual colour components. /// template -class GenericTransColour +class GenericTransColour final { public: @@ -1821,8 +1820,6 @@ class GenericTransColour friend GenericTransColour ToTransColour(const GenericRGBFTColour& col); - typedef DBL EXPRESS[5]; - /// Default constructor. inline GenericTransColour() : mColour(0.0), @@ -2101,7 +2098,7 @@ typedef GenericTransColour PreciseTransColour; ///< Hig /// Defaults to unsigned char. /// template -class GenericRGBEColour +class GenericRGBEColour final { public: @@ -2256,5 +2253,6 @@ typedef GenericRGBEColour<250,true> PhotonColour; ///< RGBE format as //############################################################################## } +// end of namespace pov_base -#endif +#endif // POVRAY_BASE_COLOUR_H diff --git a/source/base/configbase.h b/source/base/configbase.h index 625ad3f69..18b9bae02 100644 --- a/source/base/configbase.h +++ b/source/base/configbase.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,12 +38,14 @@ #ifndef POVRAY_BASE_CONFIGBASE_H #define POVRAY_BASE_CONFIGBASE_H +// Pull in other compile-time config header files first #include "syspovconfigbase.h" -#include - -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// Boost header files #include //############################################################################## @@ -59,35 +61,6 @@ /// the corresponding header files and specifying `using NAMESPACE::SYMBOL`. However, alternative /// implementations may also be provided unless noted otherwise. /// -/// The following symbols must have the same semantics as those from C++11's `std::` namespace: -/// -/// - `const_pointer_cast` -/// - `dynamic_pointer_cast` -/// - `list` -/// - `runtime_error` (should be identical to `std::runtime_error`) -/// - `shared_ptr` -/// - `static_pointer_cast` -/// - `string` -/// - `vector` -/// - `weak_ptr` -/// -/// The following symbols must have the same semantics as those from Boost's `boost::` namespace: -/// -/// - `intrusive_ptr` -/// -/// @todo -/// The following POSIX features also need to be present or emulated: -/// - `O_CREAT`, `O_RDWR`, `O_TRUNC` -/// - `S_IRUSR`, `S_IWUSR` -/// - `int open(const char*, int, int)` -/// - `int close(int)` -/// - `ssize_t write(int, const void*, size_t)` -/// - `ssize_t read(int, void*, size_t)` -/// -/// @todo -/// The following somewhat obscure macros also need to be defined: -/// - `IFF_SWITCH_CAST` -/// /// @todo /// The following macros currently default to unexpected values; also, the implementations /// they default to are currently not part of the base module: @@ -355,56 +328,16 @@ #define COLC float #endif -/// @def UCS2 -/// Data type used to represent individual UCS2 characters. -/// -/// This data type is used to represent characters from the UCS2 character set, i.e. the 16-bit -/// Basic Multilingual Plane subset of Unicode. -/// -/// This should be an unsigned character or integer type at least 16 bits wide. -/// -/// @note -/// For clarity, this data type should _not_ be used as the base type for UTF-16 encoded -/// full-fledged Unicode strings. Use @ref UTF16 instead. -/// -/// @todo -/// Currently, the actual type must be identical to that of @ref UTF16. -/// -/// @attention -/// Some legacy portions of the code may improperly use this type where they should use -/// @ref UTF16 instead. -/// -#ifndef UCS2 - #define UCS2 char16_t +// The following character types are no longer defined as macros, +// but instead use aliased or dedicated types. +#ifdef UCS2 + #error "Platform-specific configurations should no longer define UCS2 as a macro." #endif - -/// @def UCS4 -/// Integer data type used to represent UCS4 or full-fledged Unicode characters. -/// -/// This should be an unsigned character or integer type at least 21 (sic!) bits wide. -/// -#ifndef UCS4 - #define UCS4 char32_t +#ifdef UCS4 + #error "Platform-specific configurations should no longer define UCS4 as a macro." #endif - -/// @def UTF16 -/// Integer data type used as the base type to represent UTF-16 encoded Unicode strings. -/// This should be an unsigned integer type at least 16 bits wide. -/// -/// @note -/// For clarity, this data type should _not_ be used to store regular UCS2 characters -/// (16-bit Basic Multilingual Plane subset of Unicode). For that purpose, use @ref UCS2 -/// instead. -/// -/// @todo -/// Currently, the actual type must be identical to that of @ref UCS2. -/// -/// @attention -/// Some legacy portions of the code may improperly use @ref UCS2 where they should use this -/// type instead. -/// -#ifndef UTF16 - #define UTF16 UCS2 +#ifdef UTF16 + #error "Platform-specific configurations should no longer define UTF16 as a macro." #endif /// @def POV_LONG @@ -841,76 +774,45 @@ #define POV_USE_DEFAULT_PATH_PARSER 1 #endif -/// @def POV_DELETE_FILE -/// Delete a given file. +/// @def POV_USE_DEFAULT_DELETEFILE +/// Whether to use a default implementation to delete a file. /// -/// Define as a single command that erases the specified file from the file system. +/// Define as non-zero to use a default implementation for the @ref pov_base::Filesystem::DeleteFile() method, +/// or zero if the platform provides its own implementation. /// /// @note -/// There is no default implementation for this macro. -/// -/// @param[in] name UTF-8 encoded file name in system-specific format. +/// The default implementation is only provided as a last-ditch resort. Wherever possible, +/// implementations should provide their own implementation. /// -#ifndef POV_DELETE_FILE - #ifdef DOXYGEN - // just leave undefined when running doxygen - // The following two lines work around doxygen being unable to document undefined macros. - #define POV_DELETE_FILE(name) (undefined) - #undef POV_DELETE_FILE - #else - #error "No default implementation for POV_DELETE_FILE." - #endif +#ifndef POV_USE_DEFAULT_DELETEFILE + #define POV_USE_DEFAULT_DELETEFILE 1 #endif -/// @def POV_LSEEK(handle,offset,whence) -/// Seek a particular absolute or relative location in a (large) file. +/// @def POV_USE_DEFAULT_LARGEFILE +/// Whether to use a default implementation for large file handling. /// -/// Define this to `lseek64()` (GNU/Linux), `_lseeki64()` (Windows), or an equivalent function -/// supporting large files (i.e. files significantly larger than 2 GiB). +/// Define as non-zero to use a default implementation for the @ref pov_base::Filesystem::LargeFile class, +/// or zero if the platform provides its own implementation. /// /// @note -/// If large file support is unavailable, it is technically safe to substitute equivalent -/// functions taking 32 bit file offsets instead. However, this will limit output file size to -/// approx. 100 Megapixels. -/// -#ifndef POV_LSEEK - #ifdef DOXYGEN - // just leave undefined when running doxygen - // The following two lines work around doxygen being unable to document undefined macros. - #define POV_LSEEK(name) (undefined) - #undef POV_LSEEK - #else - #error "No default implementation for POV_LSEEK." - #endif +/// The current default implementation may or may not actually support large +/// files, and may provide less than optimal performance. +/// +#ifndef POV_USE_DEFAULT_LARGEFILE + #define POV_USE_DEFAULT_LARGEFILE 1 #endif /// @def POV_OFF_T /// Type representing a particular absolute or relative location in a (large) file. /// -/// Define this to the return type of `lseek64()` (GNU/Linux), `_lseeki64()` (Windows), or -/// equivalent function used in the definition of @ref POV_LSEEK(). +/// Define this to a signed integer wide enough to hold the maximum file size +/// supported by the operating system. On most modern systems, this should be +/// at least 64 bits (including the sign bit). /// #ifndef POV_OFF_T - #ifdef DOXYGEN - // just leave undefined when running doxygen - // The following two lines work around doxygen being unable to document undefined macros. - #define POV_OFF_T (undefined) - #undef POV_OFF_T - #else - #error "No default implementation for POV_OFF_T." - #endif + #define POV_OFF_T std::int_least64_t #endif -static_assert( - std::is_same::value, - "POV_OFF_T does not match return type of POV_LSEEK()." -); - -static_assert( - std::numeric_limits::max() >= std::numeric_limits::max(), - "Large files (> 2 GiB) not supported, limiting image size to approx. 100 Megapixels. Proceed at your own risk." -); - /// @} /// //****************************************************************************** @@ -1124,6 +1026,9 @@ static_assert( #define M_TAU TWO_M_PI +#define POVMSAddress void* +#define POVMSInvalidAddress nullptr + /// @} /// //****************************************************************************** diff --git a/source/base/fileinputoutput.cpp b/source/base/fileinputoutput.cpp index 97a6f423e..1f95d55a2 100644 --- a/source/base/fileinputoutput.cpp +++ b/source/base/fileinputoutput.cpp @@ -36,17 +36,21 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/fileinputoutput.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include #include -// Standard C++ header files -#include +// C++ standard header files +#include +#include -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/path.h" #include "base/platformbase.h" +#include "base/povassert.h" #include "base/pov_err.h" +#include "base/stringutilities.h" // this must be the last file included #include "base/povdebug.h" @@ -54,6 +58,9 @@ namespace pov_base { +using std::min; +using std::max; + IOBase::IOBase() : filename(), fail(true) { } @@ -323,7 +330,7 @@ IStream *NewIStream(const Path& p, unsigned int stype) { if (!PlatformBase::GetInstance().AllowLocalFileAccess(p(), stype, false)) { - string str ("IO Restrictions prohibit read access to '") ; + std::string str ("IO Restrictions prohibit read access to '") ; str += UCS2toSysString(p()); str += "'"; throw POV_EXCEPTION(kCannotOpenFileErr, str); @@ -341,7 +348,7 @@ OStream *NewOStream(const Path& p, unsigned int stype, bool sappend) if (!PlatformBase::GetInstance().AllowLocalFileAccess(p(), stype, true)) { - string str ("IO Restrictions prohibit write access to '") ; + std::string str ("IO Restrictions prohibit write access to '") ; str += UCS2toSysString(p()); str += "'"; throw POV_EXCEPTION(kCannotOpenFileErr, str); @@ -372,7 +379,7 @@ UCS2String GetFileName(const Path& p) bool CheckIfFileExists(const Path& p) { - FILE *tempf = PlatformBase::GetInstance().OpenLocalFile (p().c_str(), "r"); + FILE *tempf = PlatformBase::GetInstance().OpenLocalFile (p(), "r"); if (tempf != nullptr) fclose(tempf); @@ -384,7 +391,7 @@ bool CheckIfFileExists(const Path& p) POV_OFF_T GetFileLength(const Path& p) { - FILE *tempf = PlatformBase::GetInstance().OpenLocalFile (p().c_str(), "rb"); + FILE *tempf = PlatformBase::GetInstance().OpenLocalFile (p(), "rb"); POV_OFF_T result = -1; if (tempf != nullptr) @@ -545,3 +552,4 @@ bool IMemStream::seekg(POV_OFF_T posi, unsigned int whence) } } +// end of namespace pov_base diff --git a/source/base/fileinputoutput.h b/source/base/fileinputoutput.h index ffabfd61f..212c50bb0 100644 --- a/source/base/fileinputoutput.h +++ b/source/base/fileinputoutput.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,15 +38,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/fileinputoutput_fwd.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include -// POV-Ray base header files -#include "base/path.h" -#include "base/stringutilities.h" -#include "base/types.h" +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/path_fwd.h" +#include "base/stringtypes.h" namespace pov_base { @@ -120,7 +123,7 @@ class IStream : public IOBase public: IStream(); IStream(const UCS2String& name); - virtual ~IStream(); + virtual ~IStream() override; virtual bool read(void *buffer, size_t exactCount) = 0; virtual size_t readUpTo(void *buffer, size_t maxCount) = 0; @@ -144,23 +147,23 @@ class IStream : public IOBase /// /// This class provides file read access. /// -class IFileStream : public IStream +class IFileStream final : public IStream { public: IFileStream(const UCS2String& name); - virtual ~IFileStream(); + virtual ~IFileStream() override; - virtual bool eof() const { return(fail ? true : feof(f) != 0); } - virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set); - virtual POV_OFF_T tellg() const { return(f == nullptr ? -1 : ftell(f)); } - virtual bool clearstate() { if (f != nullptr) fail = false; return !fail; } + virtual bool eof() const override { return(fail ? true : feof(f) != 0); } + virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set) override; + virtual POV_OFF_T tellg() const override { return(f == nullptr ? -1 : ftell(f)); } + virtual bool clearstate() override { if (f != nullptr) fail = false; return !fail; } - virtual bool read(void *buffer, size_t exactCount); - virtual size_t readUpTo(void *buffer, size_t maxCount); - virtual bool getline(char *s, size_t buflen); - virtual int Read_Byte(); + virtual bool read(void *buffer, size_t exactCount) override; + virtual size_t readUpTo(void *buffer, size_t maxCount) override; + virtual bool getline(char *s, size_t buflen) override; + virtual int Read_Byte() override; - virtual bool UnRead_Byte(int c); + virtual bool UnRead_Byte(int c) override; protected: FILE *f; @@ -173,23 +176,23 @@ class IFileStream : public IStream /// /// This class is used to support in-built fonts and cached macros. /// -class IMemStream : public IStream +class IMemStream final : public IStream { public: IMemStream(const unsigned char* data, size_t size, const char* formalName, POV_OFF_T formalStart = 0); IMemStream(const unsigned char* data, size_t size, const UCS2String& formalName, POV_OFF_T formalStart = 0); - virtual ~IMemStream(); + virtual ~IMemStream() override; - virtual int Read_Byte(); - virtual bool UnRead_Byte(int c); - virtual bool getline(char *s, size_t buflen); - virtual POV_OFF_T tellg() const; - virtual bool read(void *buffer, size_t exactCount); - virtual size_t readUpTo(void *buffer, size_t count); - virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set); - virtual bool clearstate() { fail = false; return true; } + virtual int Read_Byte() override; + virtual bool UnRead_Byte(int c) override; + virtual bool getline(char *s, size_t buflen) override; + virtual POV_OFF_T tellg() const override; + virtual bool read(void *buffer, size_t exactCount) override; + virtual size_t readUpTo(void *buffer, size_t count) override; + virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set) override; + virtual bool clearstate() override { fail = false; return true; } - virtual bool eof() const { return fail; } + virtual bool eof() const override { return fail; } protected: @@ -204,12 +207,12 @@ class OStream : public IOBase { public: OStream(const UCS2String& name, unsigned int Flags = 0); - ~OStream(); + virtual ~OStream() override; - virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set); - virtual POV_OFF_T tellg() const { return(f == nullptr ? -1 : ftell(f)); } - inline bool clearstate() { if (f != nullptr) fail = false; return !fail; } - virtual bool eof() const { return(fail ? true : feof(f) != 0); } + virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set) override; + virtual POV_OFF_T tellg() const override { return(f == nullptr ? -1 : ftell(f)); } + virtual inline bool clearstate() override { if (f != nullptr) fail = false; return !fail; } + virtual bool eof() const override { return(fail ? true : feof(f) != 0); } bool write(const void *buffer, size_t count); void printf(const char *format, ...); @@ -224,16 +227,17 @@ class OStream : public IOBase IStream *NewIStream(const Path&, unsigned int); OStream *NewOStream(const Path&, unsigned int, bool); -UCS2String GetFileExtension(const Path& p); -UCS2String GetFileName(const Path& p); +UCS2String GetFileExtension(const Path& p); ///< @todo Move this to the @ref Path class. +UCS2String GetFileName(const Path& p); ///< @todo Move this to the @ref Path class. -bool CheckIfFileExists(const Path& p); -POV_OFF_T GetFileLength(const Path& p); +bool CheckIfFileExists(const Path& p); ///< @todo Move this to the @ref PlatformBase class. +POV_OFF_T GetFileLength(const Path& p); ///< @todo Move this to the @ref PlatformBase class. /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_FILEINPUTOUTPUT_H diff --git a/source/base/fileinputoutput_fwd.h b/source/base/fileinputoutput_fwd.h new file mode 100644 index 000000000..2190f3172 --- /dev/null +++ b/source/base/fileinputoutput_fwd.h @@ -0,0 +1,52 @@ +//****************************************************************************** +/// +/// @file base/fileinputoutput_fwd.h +/// +/// Forward declarations related to basic file input and output. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_FILEINPUTOUTPUT_FWD_H +#define POVRAY_BASE_FILEINPUTOUTPUT_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class IStream; +class OStream; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_FILEINPUTOUTPUT_FWD_H diff --git a/source/base/filesystem.cpp b/source/base/filesystem.cpp new file mode 100644 index 000000000..c7e072b9e --- /dev/null +++ b/source/base/filesystem.cpp @@ -0,0 +1,208 @@ +//****************************************************************************** +/// +/// @file base/filesystem.cpp +/// +/// Implementation of file system services (default implementation). +/// +/// @note +/// This is a default implementation, provided primarily as a template for +/// creating platform-specific implementations. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "base/filesystem.h" + +// C++ variants of C standard header files +#if POV_USE_DEFAULT_DELETEFILE +#include +#endif + +// C++ standard header files +#if POV_USE_DEFAULT_LARGEFILE +#include +#include +#include +#endif +#if POV_USE_DEFAULT_TEMPORARYFILE +#include +#endif + +// POV-Ray header files (base module) +#if POV_USE_DEFAULT_DELETEFILE || POV_USE_DEFAULT_LARGEFILE || POV_USE_DEFAULT_TEMPORARYFILE +#include "base/stringutilities.h" +#endif + +// this must be the last file included +#include "base/povdebug.h" + +namespace pov_base +{ + +namespace Filesystem +{ + +//****************************************************************************** + +#if POV_USE_DEFAULT_DELETEFILE + +bool DeleteFile(const UCS2String& fileName) +{ + // Note: The C++ standard does not specify whether `remove` will or will not + // delete directories. On POSIX systems it will, which is not ideal for our + // purposes. + return (std::remove(UCS2toSysString(fileName).c_str()) == 0); +} + +#endif // POV_USE_DEFAULT_DELETEFILE + +//****************************************************************************** + +#if POV_USE_DEFAULT_LARGEFILE + +using Offset = std::streamoff; + +static_assert( + std::numeric_limits::digits > 32, + "Large files (> 2 GiB) not supported, limiting image size to approx. 100 Megapixels. Proceed at your own risk." + ); + +struct LargeFile::Data final +{ + std::fstream stream; +}; + +LargeFile::LargeFile() : + mpData(new Data) +{ + // Disable stream buffering. + mpData->stream.rdbuf()->pubsetbuf(nullptr, 0); +} + +LargeFile::~LargeFile() +{ + Close(); +} + +bool LargeFile::CreateRW(const UCS2String& fileName) +{ + mpData->stream.open(UCS2toSysString(fileName), + std::ios_base::binary | std::ios_base::in | std::ios_base::out | std::ios_base::trunc); + return mpData->stream.is_open(); +} + +bool LargeFile::Seek(std::int_least64_t offset) +{ + if (!mpData->stream.is_open() || mpData->stream.bad()) + return false; + if ((offset < 0) || (offset > std::numeric_limits::max())) + return false; + return (mpData->stream.rdbuf()->pubseekpos(Offset(offset), + std::ios_base::in | std::ios_base::out) == offset); +} + +std::size_t LargeFile::Read(void* data, std::size_t maxSize) +{ + if (!mpData->stream.is_open() || mpData->stream.bad()) + return false; + return mpData->stream.read(reinterpret_cast(data), maxSize).gcount(); +} + +bool LargeFile::Write(const void* data, std::size_t size) +{ + if (!mpData->stream.is_open() || mpData->stream.bad()) + return false; + return !mpData->stream.write(reinterpret_cast(data), size).bad(); +} + +void LargeFile::Close() +{ + if (mpData->stream.is_open()) + mpData->stream.close(); +} + +#endif // POV_USE_DEFAULT_LARGEFILE + +//****************************************************************************** + +TemporaryFile::TemporaryFile() : + mFileName(SuggestName()) +{} + +TemporaryFile::TemporaryFile(const UCS2String& name) : + mFileName(name) +{} + +TemporaryFile::~TemporaryFile() +{ + Delete(); +} + +const UCS2String& TemporaryFile::GetFileName() const +{ + return mFileName; +} + +void TemporaryFile::Keep() +{ + mFileName.clear(); +} + +void TemporaryFile::Delete() +{ + if (!mFileName.empty()) + { + (void)DeleteFile(mFileName); + mFileName.clear(); + } +} + +#if POV_USE_DEFAULT_TEMPORARYFILE + +UCS2String TemporaryFile::SuggestName() +{ + static std::atomic_int globalIndex = 0; + int index = globalIndex++; + + char buffer[32]; + sprintf(buffer, "/tmp/pov%08x.dat", index); + + return ASCIItoUCS2String(buffer); +} + +#endif // POV_USE_DEFAULT_TEMPORARYFILE + +//****************************************************************************** + +} +// end of namespace Filesystem + +} +// end of namespace pov_base diff --git a/source/base/filesystem.h b/source/base/filesystem.h new file mode 100644 index 000000000..67f53162e --- /dev/null +++ b/source/base/filesystem.h @@ -0,0 +1,217 @@ +//****************************************************************************** +/// +/// @file base/filesystem.h +/// +/// Declaration of file system services (default implementation). +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_FILESYSTEM_H +#define POVRAY_BASE_FILESYSTEM_H + +// Module config header file must be the first file included within POV-Ray unit header files +#include "base/configbase.h" +#include "base/filesystem_fwd.h" + +// C++ variants of C standard header files +#include // Pulled in for `std::int_least64_t`. +#include // Pulled in for `std::size_t`. + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/stringtypes.h" + +namespace pov_base +{ + +/// File System Handling. +/// @ingroup PovBase +/// +namespace Filesystem +{ + +#ifdef DeleteFile +#undef DeleteFile // Shame on you, Windows! +#endif + +/// Delete file. +/// +/// This function shall try to delete (or, more specifically, "unlink") the +/// specified file. +/// +/// @note +/// If the file does not exist, the return value is currently undefined. +/// +/// @note +/// If the file is a directory, the function should fail (but callers are +/// advised to not rely on this property). +/// +/// @note +/// The default implementation has some limitations; specifically, it only +/// supports file names comprised of the _narrow execution character set_, +/// and on some platforms may happily delete directories. Platforms are +/// strongly encouraged to provide their own implementation. +/// +/// @param fileName Name of the file to delete. +/// @return `true` if the file was deleted, `false` otherwise. +/// +bool DeleteFile(const UCS2String& fileName); + +/// Large file handling. +/// +/// This class provides basic random access to large (>2 GiB) files. +/// +/// @note +/// Implementations should be optimized for random access of several dozen +/// kByte at a time; typically, this means implementations should refrain +/// from buffering. +/// +/// @note +/// The default implementation of this function may or may not support files +/// larger than 2 GiB, and performance may be less than optimal. Platforms +/// are encouraged to provide their own implementation. +/// +class LargeFile final +{ +public: + + LargeFile(); + ~LargeFile(); + + /// Create file for read/write access. + /// @note + /// If the file already exists, it should be truncated to zero size. + bool CreateRW(const UCS2String& fileName); + + /// Seek in file. + bool Seek(std::int_least64_t offset); + + /// Read from file. + std::size_t Read(void* data, std::size_t maxSize); + + /// Write to file. + bool Write(const void* data, std::size_t size); + + /// Close file. + void Close(); + +private: + + struct Data; + std::unique_ptr mpData; +}; + +/// Temporary file tracker. +/// +/// This class can be used to make sure that a given file is automatically +/// deleted, based on the lifetime of this object. +/// +class TemporaryFile final +{ +public: + + /// Track a file with an auto-generated name. + /// + /// This constructor associates the object with a new unique file name in + /// a location well-suited for temporary files. The name of the file can be + /// queried via @ref GetFileName(). + /// + /// @note + /// The constructor may or may not auto-create an empty file with the + /// generated name. + /// + explicit TemporaryFile(); + + explicit TemporaryFile(const TemporaryFile&) = delete; + + /// Track a caller-specified file. + /// + /// This constructor associates the object with a caller-specified + /// file name. + /// + explicit TemporaryFile(const UCS2String& name); + + /// Delete tracked file. + ~TemporaryFile(); + + /// Get associated file name. + const UCS2String& GetFileName() const; + + /// Keep file. + /// + /// Calling this method will disassociate the file, such that it will _not_ + /// be deleted upon object destruction. + /// @note + /// Once this method has been called, it is no longer possible to query + /// the name of the file originally associated. + /// + void Keep(); + + /// Delete file. + /// + /// Calling this method will delete the file early. + /// @note + /// Once this method has been called, it is no longer possible to query + /// the name of the file originally associated. + /// + void Delete(); + +private: + + /// Suggest name for temporary file. + /// + /// This method suggests a new unique file name in a location well-suited + /// for temporary files. + /// + /// @note + /// The method may or may not auto-create an empty file with the + /// generated name, depending on what is easiest and/or best suited to + /// the algorithm by which names are generated. + /// + /// @note + /// The default implementation is less than optimal, potentially choosing + /// an unsuited location or generating duplicate names under certain + /// conditions. Platforms should provide their own implementation of this + /// method. + /// + static UCS2String SuggestName(); + + UCS2String mFileName; ///< Associated file name, or empty string if not applicable. +}; + +} +// end of namespace Filesystem + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_FILESYSTEM_H diff --git a/source/base/filesystem_fwd.h b/source/base/filesystem_fwd.h new file mode 100644 index 000000000..08ac0a636 --- /dev/null +++ b/source/base/filesystem_fwd.h @@ -0,0 +1,61 @@ +//****************************************************************************** +/// +/// @file base/filesystem_fwd.h +/// +/// Forward declarations related to file system services. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_FILESYSTEM_FWD_H +#define POVRAY_BASE_FILESYSTEM_FWD_H + +// C++ standard header files +#include + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +namespace Filesystem +{ + +class TemporaryFile; +using TemporaryFilePtr = std::shared_ptr; + +} +// end of namespace Filesystem + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_FILESYSTEM_FWD_H diff --git a/source/base/fileutil.cpp b/source/base/fileutil.cpp index cfefabe13..55f7ef660 100644 --- a/source/base/fileutil.cpp +++ b/source/base/fileutil.cpp @@ -38,12 +38,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/fileutil.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include -#include -// POV-Ray base header files +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/path.h" +#include "base/stringutilities.h" // All the builtin fonts must be declared here #include "base/font/crystal.h" @@ -59,13 +63,13 @@ namespace pov_base /* // not used right now -typedef struct +struct POV_File_Restrictions final { bool read_local; bool read_global; bool write_local; bool write_global; -} POV_File_Restrictions; +}; POV_File_Restrictions gPOV_File_Restrictions[POV_File_Count] = { @@ -173,7 +177,7 @@ int InferFileTypeFromExt(const UCS2String& ext) { // TODO FIXME - better compare in the string domain - string str = UCS2toSysString(ext); + std::string str = UCS2toSysString(ext); for (int i = 0; i < POV_File_Count; i++) { @@ -226,7 +230,7 @@ int InferFileTypeFromExt(const UCS2String& ext) * * To add a font, check first its license */ -IMemStream *Internal_Font_File(int font_id) +IStream *Internal_Font_File(int font_id) { switch(font_id) { @@ -240,3 +244,4 @@ IMemStream *Internal_Font_File(int font_id) //****************************************************************************** } +// end of namespace pov_base diff --git a/source/base/fileutil.h b/source/base/fileutil.h index f4ae1a6b8..fa572b7e1 100644 --- a/source/base/fileutil.h +++ b/source/base/fileutil.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,9 +39,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/fileinputoutput.h" -#include "base/stringutilities.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/stringtypes.h" namespace pov_base { @@ -53,9 +57,6 @@ namespace pov_base /// /// @{ -class IMemStream; -class IStream; - // Legal image file attributes. #define NO_FILE 0x00000000 @@ -76,7 +77,7 @@ class IStream; #define POV_FILE_EXTENSIONS_PER_TYPE 4 -struct POV_File_Extensions +struct POV_File_Extensions final { const char *ext[POV_FILE_EXTENSIONS_PER_TYPE]; }; @@ -85,12 +86,13 @@ extern POV_File_Extensions gPOV_File_Extensions[]; extern const int gFile_Type_To_Mask[]; int InferFileTypeFromExt(const pov_base::UCS2String& ext); -IMemStream *Internal_Font_File(int font_id); +IStream *Internal_Font_File(int font_id); /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_FILEUTIL_H diff --git a/source/base/image/bmp.cpp b/source/base/image/bmp.cpp index 4acce9279..c1ecd6dcd 100644 --- a/source/base/image/bmp.cpp +++ b/source/base/image/bmp.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,11 +38,18 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/bmp.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" // this must be the last file included #include "base/povdebug.h" @@ -454,7 +461,7 @@ static void Read_BMP_8b_RLE(Image *image, IStream& in, unsigned width, unsigned * ******************************************************************************/ -void Write (OStream *file, const Image *image, const Image::WriteOptions& options) +void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { int width = image->GetWidth(); int height = image->GetHeight(); @@ -518,7 +525,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option throw POV_EXCEPTION(kFileDataErr, "Error writing to BMP file") ; } -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { unsigned file_width, file_height; unsigned file_depth, file_colors; @@ -592,7 +599,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) if (file_depth < 24) { int color_map_length = file_colors ? file_colors : 1< colormap ; + std::vector colormap ; Image::RGBMapEntry entry; for (int i=0; ieof ()) throw POV_EXCEPTION(kFileDataErr, "Unexpected EOF while reading BMP file"); - image = Image::Create (file_width, file_height, Image::Colour_Map, colormap) ; + image = Image::Create (file_width, file_height, ImageDataType::Colour_Map, colormap) ; image->SetPremultiplied(premul); // specify whether the color map data has premultiplied alpha switch (file_depth) @@ -649,17 +656,10 @@ Image *Read (IStream *file, const Image::ReadOptions& options) } else { - /* includes update from stefan maierhofer for 32bit */ - Image::ImageDataType imagetype = options.itype ; - if (imagetype == Image::Undefined) - { - if (GammaCurve::IsNeutral(gamma)) - // No gamma correction required, raw values can be stored "as is". - imagetype = has_alpha ? Image::RGBA_Int8 : Image::RGB_Int8 ; - else - // Gamma correction required; use an image container that will take care of that. - imagetype = has_alpha ? Image::RGBA_Gamma8 : Image::RGB_Gamma8 ; - } + /* includes update from Stefan Maierhofer for 32bit */ + ImageDataType imagetype = options.itype ; + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(8, 3, has_alpha, gamma); image = Image::Create (file_width, file_height, imagetype) ; image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication image->TryDeferDecoding(gamma, 255); // try to have gamma adjustment being deferred until image evaluation. @@ -687,6 +687,8 @@ Image *Read (IStream *file, const Image::ReadOptions& options) } -} // end of namespace Bmp +} +// end of namespace Bmp } +// end of namespace pov_base diff --git a/source/base/image/bmp.h b/source/base/image/bmp.h index 9cf66ba17..70f0a897f 100644 --- a/source/base/image/bmp.h +++ b/source/base/image/bmp.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -54,15 +59,17 @@ namespace pov_base namespace Bmp { -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); } +// end of namespace Bmp /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_BMP_H diff --git a/source/base/image/colourspace.cpp b/source/base/image/colourspace.cpp index 232e28dab..eadbb7d32 100644 --- a/source/base/image/colourspace.cpp +++ b/source/base/image/colourspace.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,11 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/colourspace.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/povassert.h" #include "base/image/encoding.h" // this must be the last file included @@ -49,8 +52,11 @@ namespace pov_base { +using std::min; +using std::max; + // definitions of static GammaCurve member variables to satisfy the linker -list > GammaCurve::cache; +std::list> GammaCurve::cache; #if POV_MULTITHREADED boost::mutex GammaCurve::cacheMutex; #endif @@ -106,7 +112,7 @@ GammaCurvePtr GammaCurve::GetMatching(const GammaCurvePtr& newInstance) // Check if we already have created a matching gamma curve object; if so, return that object instead. // Also, make sure we get the new object stored (as we're using weak pointers, we may have stale entries; // it also won't hurt if we store the new instance, even if we decide to discard it) - for(list >::iterator i(cache.begin()); i != cache.end(); i++) + for(std::list>::iterator i(cache.begin()); i != cache.end(); i++) { oldInstance = (*i).lock(); if (!oldInstance) @@ -301,7 +307,7 @@ SimpleGammaCurvePtr PowerLawGammaCurve::GetByEncodingGamma(float gamma) { if (IsNeutral(gamma)) return NeutralGammaCurve::Get(); - return dynamic_pointer_cast(GetMatching(GammaCurvePtr(new PowerLawGammaCurve(gamma)))); + return std::dynamic_pointer_cast(GetMatching(GammaCurvePtr(new PowerLawGammaCurve(gamma)))); } SimpleGammaCurvePtr PowerLawGammaCurve::GetByDecodingGamma(float gamma) { @@ -448,3 +454,4 @@ SimpleGammaCurvePtr GetGammaCurve(GammaTypeId type, float param) } } +// end of namespace pov_base diff --git a/source/base/image/colourspace.h b/source/base/image/colourspace.h index 043f25043..21a2d16e8 100644 --- a/source/base/image/colourspace.h +++ b/source/base/image/colourspace.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,18 +38,22 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/image/colourspace_fwd.h" -// Standard C++ header files -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include // Boost header files #if POV_MULTITHREADED #include #endif -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/colour.h" -#include "base/types.h" namespace pov_base { @@ -61,15 +65,6 @@ namespace pov_base /// /// @{ -class GammaCurve; -class SimpleGammaCurve; - -/// Class holding a shared reference to a gamma curve. -typedef shared_ptr GammaCurvePtr; - -/// Class holding a shared reference to a simple gamma curve. -typedef shared_ptr SimpleGammaCurvePtr; - /// Abstract class representing an encoding gamma curve (or, more generally, transfer function). /// /// In this generic form, the gamma curve may be arbitrarily complex. @@ -342,7 +337,7 @@ class GammaCurve /// This static member variable caches pointers of gamma curve instances currently in use, forming the basis /// of the `GetMatching()` mechanism to avoid duplicate instances. /// - static list > cache; + static std::list> cache; #if POV_MULTITHREADED /// Mutex to guard access to `cache`. @@ -393,7 +388,7 @@ class SimpleGammaCurve : public GammaCurve /// @param[in] p Pointer to the gamma curve to compare with. /// @return `true` if the gamma curve will produce the same result as this instance, `false` otherwise. /// - virtual bool Matches(const GammaCurvePtr& p) const + virtual bool Matches(const GammaCurvePtr& p) const override { SimpleGammaCurve* simpleP = dynamic_cast(p.get()); if (simpleP) @@ -412,7 +407,7 @@ class UniqueGammaCurve : public SimpleGammaCurve /// /// This function is to be implemented by subclasses to return the type-specific parameter of the gamma curve subclass. /// - virtual float GetParam() const { return 0.0; } + virtual float GetParam() const override { return 0.0; } protected: @@ -423,7 +418,7 @@ class UniqueGammaCurve : public SimpleGammaCurve /// @param[in] p Pointer to the gamma curve to compare with. /// @return `true` if the gamma curve will produce the same result as this instance, `false` otherwise. /// - virtual bool Matches(const GammaCurvePtr& p) const + virtual bool Matches(const GammaCurvePtr& p) const override { UniqueGammaCurve* uniqueP = dynamic_cast(p.get()); if (uniqueP) @@ -434,18 +429,18 @@ class UniqueGammaCurve : public SimpleGammaCurve }; /// Class representing a neutral gamma curve. -class NeutralGammaCurve : public UniqueGammaCurve +class NeutralGammaCurve final : public UniqueGammaCurve { public: static SimpleGammaCurvePtr Get(); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; private: static SimpleGammaCurvePtr instance; - virtual bool Matches(const GammaCurvePtr&) const; - virtual bool IsNeutral() const; + virtual bool Matches(const GammaCurvePtr&) const override; + virtual bool IsNeutral() const override; NeutralGammaCurve(); }; @@ -455,14 +450,14 @@ class NeutralGammaCurve : public UniqueGammaCurve /// having a constant gamma of 1/2.2, the two are not identical. This class represents /// the exact function as specified in IEC 61966-2-1. /// -class SRGBGammaCurve : public UniqueGammaCurve +class SRGBGammaCurve final : public UniqueGammaCurve { public: static SimpleGammaCurvePtr Get(); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; private: static SimpleGammaCurvePtr instance; SRGBGammaCurve(); @@ -475,14 +470,14 @@ class SRGBGammaCurve : public UniqueGammaCurve /// @note This class does _not_ account for the "black digital count" and "white digital count" being defined /// as 16/255 and 235/255, respectively. /// -class BT709GammaCurve : public UniqueGammaCurve +class BT709GammaCurve final : public UniqueGammaCurve { public: static SimpleGammaCurvePtr Get(); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; private: static SimpleGammaCurvePtr instance; BT709GammaCurve(); @@ -492,14 +487,14 @@ class BT709GammaCurve : public UniqueGammaCurve /// /// This transfer function is a wide-gamut extension to that specified in ITU-R BT.709. /// -class BT1361GammaCurve : public UniqueGammaCurve +class BT1361GammaCurve final : public UniqueGammaCurve { public: static SimpleGammaCurvePtr Get(); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; private: static SimpleGammaCurvePtr instance; BT1361GammaCurve(); @@ -513,51 +508,51 @@ class BT1361GammaCurve : public UniqueGammaCurve /// @note This class does _not_ account for the "black digital count" and "white digital count" being defined /// as 16/255 and 235/255, respectively. /// -class BT2020GammaCurve : public UniqueGammaCurve +class BT2020GammaCurve final : public UniqueGammaCurve { public: static SimpleGammaCurvePtr Get(); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; private: static SimpleGammaCurvePtr instance; BT2020GammaCurve(); }; /// Class representing a classic constant-gamma (power-law) gamma encoding curve. -class PowerLawGammaCurve : public SimpleGammaCurve +class PowerLawGammaCurve final : public SimpleGammaCurve { public: static SimpleGammaCurvePtr GetByEncodingGamma(float gamma); static SimpleGammaCurvePtr GetByDecodingGamma(float gamma); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; - virtual float GetParam() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; + virtual float GetParam() const override; protected: float encGamma; PowerLawGammaCurve(float encGamma); - virtual bool Matches(const GammaCurvePtr&) const; + virtual bool Matches(const GammaCurvePtr&) const override; static bool IsNeutral(float gamma); }; /// Class representing a scaled-encoding variant of another gamma curves. -class ScaledGammaCurve : public GammaCurve +class ScaledGammaCurve final : public GammaCurve { public: static GammaCurvePtr GetByEncoding(const GammaCurvePtr&, float encodingFactor); static GammaCurvePtr GetByDecoding(float decodingFactor, const GammaCurvePtr&); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; protected: GammaCurvePtr baseGamma; float encFactor; ScaledGammaCurve(const GammaCurvePtr&, float); - virtual bool Matches(const GammaCurvePtr&) const; + virtual bool Matches(const GammaCurvePtr&) const override; static bool IsNeutral(float factor); }; @@ -565,22 +560,22 @@ class ScaledGammaCurve : public GammaCurve /// /// @note This class is only required for backward compatibility with POV-Ray v3.6. /// -class TranscodingGammaCurve : public GammaCurve +class TranscodingGammaCurve final : public GammaCurve { public: static GammaCurvePtr Get(const GammaCurvePtr& working, const GammaCurvePtr& encoding); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; protected: GammaCurvePtr workGamma; GammaCurvePtr encGamma; TranscodingGammaCurve(); TranscodingGammaCurve(const GammaCurvePtr&, const GammaCurvePtr&); - virtual bool Matches(const GammaCurvePtr&) const; + virtual bool Matches(const GammaCurvePtr&) const override; }; -enum GammaTypeId +enum GammaTypeId : int { kPOVList_GammaType_Unknown, kPOVList_GammaType_Neutral, @@ -603,5 +598,6 @@ SimpleGammaCurvePtr GetGammaCurve(GammaTypeId typeId, float param); //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_COLOURSPACE_H diff --git a/source/base/image/colourspace_fwd.h b/source/base/image/colourspace_fwd.h new file mode 100644 index 000000000..55ee33371 --- /dev/null +++ b/source/base/image/colourspace_fwd.h @@ -0,0 +1,60 @@ +//****************************************************************************** +/// +/// @file base/image/colourspace_fwd.h +/// +/// Forward declarations related to colour space conversions. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_COLOURSPACE_FWD_H +#define POVRAY_BASE_COLOURSPACE_FWD_H + +// C++ standard header files +#include + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class GammaCurve; +typedef std::shared_ptr GammaCurvePtr; ///< Class holding a shared reference to a gamma curve. + +class SimpleGammaCurve; +typedef std::shared_ptr SimpleGammaCurvePtr; ///< Class holding a shared reference to a simple gamma curve. + +enum GammaTypeId : int; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_DITHER_FWD_H diff --git a/source/base/image/dither.cpp b/source/base/image/dither.cpp index d1fc259cb..85f1d6242 100644 --- a/source/base/image/dither.cpp +++ b/source/base/image/dither.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,10 +36,12 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/dither.h" -// Standard C++ header files -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) // POV-Ray header files (base module) +#include "base/povassert.h" #include "base/data/bluenoise64a.h" // this must be the last file included @@ -58,7 +60,7 @@ void NoDither::GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, C //******************************************************************************* -class OrderedDither::Pattern +class OrderedDither::Pattern final { public: template Pattern(unsigned int size, const T* raw, unsigned int rank); @@ -256,7 +258,7 @@ void FloydSteinbergDither::SetError(unsigned int x, unsigned int y, const Colour //******************************************************************************* -class DiffusionDither::Filter +class DiffusionDither::Filter final { public: Filter(std::initializer_list> raw, int drop = 0); @@ -426,4 +428,5 @@ ColourChannel GetDitherOffset(unsigned int x, unsigned int y) return BlueNoise64a(x, y); } -} // end of namespace pov_base +} +// end of namespace pov_base diff --git a/source/base/image/dither.h b/source/base/image/dither.h index 6939277c6..16e3f024e 100644 --- a/source/base/image/dither.h +++ b/source/base/image/dither.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,15 +33,22 @@ /// //****************************************************************************** -#ifndef POVRAY_BASE_IMAGE_DITHER_H -#define POVRAY_BASE_IMAGE_DITHER_H +#ifndef POVRAY_BASE_DITHER_H +#define POVRAY_BASE_DITHER_H // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/image/dither_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include // POV-Ray header files (base module) -#include "base/types.h" #include "base/colour.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -53,8 +60,6 @@ namespace pov_base /// /// @{ -class Image; - //***************************************************************************** /// /// @name Dithering @@ -126,7 +131,7 @@ class DitherStrategy virtual void SetError(unsigned int x, unsigned int y, const ColourOffset& err) {} }; -struct DitherStrategy::ColourOffset +struct DitherStrategy::ColourOffset final { union { ColourChannel red, gray; }; ColourChannel green, blue, alpha; @@ -142,7 +147,7 @@ struct DitherStrategy::ColourOffset inline ColourOffset& operator+=(const ColourOffset& b) { red += b.red; green += b.green; blue += b.blue; alpha += b.alpha; return *this; } }; -typedef shared_ptr DitherStrategySPtr; +typedef std::shared_ptr DitherStrategySPtr; /// Factory function to get a dithering algorithm and state. DitherStrategySPtr GetDitherStrategy(DitherMethodId method, unsigned int imageWidth); @@ -171,7 +176,7 @@ ColourChannel GetDitherOffset(unsigned int x, unsigned int y); /// This stateless dithering strategy serves as a placeholder when dithering /// is not desired. /// -class NoDither : public DitherStrategy +class NoDither final : public DitherStrategy { public: virtual void GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, ColourOffset& offQnt) override; @@ -184,7 +189,7 @@ class NoDither : public DitherStrategy /// This stateless dithering strategy implements a generalized ordered /// dithering filter. The specifics of the filter are defined by a matrix. /// -class OrderedDither : public DitherStrategy +class OrderedDither final : public DitherStrategy { public: class Pattern; @@ -232,7 +237,7 @@ extern const OrderedDither::Pattern BlueNoise64a; /// DiffusionDither::Filter( /// {{ 1 }}); /// -class DiffusionDither1D : public DitherStrategy +class DiffusionDither1D final : public DitherStrategy { public: virtual void GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, ColourOffset& offQnt) override; @@ -258,11 +263,11 @@ class DiffusionDither1D : public DitherStrategy /// {{ 2 }, /// { 1, 1, 0 }}); /// -class SierraLiteDither : public DitherStrategy +class SierraLiteDither final : public DitherStrategy { public: SierraLiteDither(unsigned int width); - virtual ~SierraLiteDither(); + virtual ~SierraLiteDither() override; virtual void GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, ColourOffset& offQnt) override; virtual void SetError(unsigned int x, unsigned int y, const ColourOffset& err) override; protected: @@ -288,11 +293,11 @@ class SierraLiteDither : public DitherStrategy /// {{ 7 }, /// { 3, 5, 1 }}); /// -class FloydSteinbergDither : public DitherStrategy +class FloydSteinbergDither final : public DitherStrategy { public: FloydSteinbergDither(unsigned int width); - virtual ~FloydSteinbergDither(); + virtual ~FloydSteinbergDither() override; virtual void GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, ColourOffset& offQnt) override; virtual void SetError(unsigned int x, unsigned int y, const ColourOffset& err) override; protected: @@ -310,12 +315,12 @@ class FloydSteinbergDither : public DitherStrategy /// /// @note This implementation uses an additional multi-line pixel buffer to avoid manipulating the original image. /// -class DiffusionDither : public DitherStrategy +class DiffusionDither final : public DitherStrategy { public: class Filter; DiffusionDither(const Filter& matrix, unsigned int width); - virtual ~DiffusionDither(); + virtual ~DiffusionDither() override; virtual void GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, ColourOffset& offQnt) override; virtual void SetError(unsigned int x, unsigned int y, const ColourOffset& err) override; protected: @@ -381,6 +386,7 @@ extern const DiffusionDither::Filter StuckiMatrix; /// //############################################################################## -} // end of namespace pov_base +} +// end of namespace pov_base #endif // POVRAY_BASE_IMAGE_DITHER_H diff --git a/source/base/image/dither_fwd.h b/source/base/image/dither_fwd.h new file mode 100644 index 000000000..5e568b37a --- /dev/null +++ b/source/base/image/dither_fwd.h @@ -0,0 +1,55 @@ +//****************************************************************************** +/// +/// @file base/image/dither_fwd.h +/// +/// Forward declarations related to image dithering. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_DITHER_FWD_H +#define POVRAY_BASE_DITHER_FWD_H + +// C++ standard header files +#include + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class DitherStrategy; +using DitherStrategySPtr = std::shared_ptr; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_DITHER_FWD_H diff --git a/source/base/image/encoding.cpp b/source/base/image/encoding.cpp index f751b67a5..896f214d6 100644 --- a/source/base/image/encoding.cpp +++ b/source/base/image/encoding.cpp @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -37,7 +37,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/encoding.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + // POV-Ray header files (base module) +#include "base/image/colourspace.h" #include "base/image/dither.h" #include "base/image/image.h" @@ -47,6 +54,40 @@ namespace pov_base { +using std::min; +using std::max; + +//***************************************************************************** + +float IntDecode(const GammaCurvePtr& g, unsigned int x, unsigned int max) +{ + return GammaCurve::Decode(g, IntDecode(x, max)); +} + +unsigned int IntEncode(const GammaCurvePtr& g, float x, unsigned int max, float qOff, float& err) +{ + if (GammaCurve::IsNeutral(g)) + return IntEncode(x, max, qOff, err); + + float xEff = clip(x, 0.0f, 1.0f) + err; + unsigned int v = IntEncodeDown(GammaCurve::Encode(g, xEff), max); + float decoded = IntDecode(g, v, max); + if (v >= max) + { + err = xEff - decoded; + return v; + } + float decodedUp = IntDecode(g, v + 1, max); + float threshold = (0.5 - qOff) * decoded + (0.5 + qOff) * decodedUp; + if (xEff > threshold) + { + decoded = decodedUp; + ++v; + } + err = xEff - decoded; + return v; +} + /*******************************************************************************/ #define ALPHA_EPSILON 1.0e-6 ///< Smallest alpha value we dare to safely use with premultiplied alpha. @@ -430,3 +471,4 @@ void GetEncodedRGBValue(const Image* img, unsigned int x, unsigned int y, const } } +// end of namespace pov_base diff --git a/source/base/image/encoding.h b/source/base/image/encoding.h index f4e444efd..4b23fd9d3 100644 --- a/source/base/image/encoding.h +++ b/source/base/image/encoding.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,17 +40,22 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files +// C++ variants of C standard header files +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/colour.h" #include "base/mathutil.h" -#include "base/types.h" -#include "base/image/colourspace.h" +#include "base/image/colourspace_fwd.h" +#include "base/image/dither_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { -class DitherStrategy; -class Image; - //############################################################################## /// /// @defgroup PovBaseImageEncoding Basic Colour Encoding and Decoding @@ -89,10 +94,7 @@ inline float IntDecode(unsigned int x, unsigned int max) /// @param[in] x Value to decode. /// @param max Encoded value representing 1.0. /// -inline float IntDecode(const GammaCurvePtr& g, unsigned int x, unsigned int max) -{ - return GammaCurve::Decode(g, IntDecode(x, max)); -} +float IntDecode(const GammaCurvePtr& g, unsigned int x, unsigned int max); /// @} /// @@ -119,7 +121,9 @@ inline float IntDecode(const GammaCurvePtr& g, unsigned int x, unsigned int max) /// inline unsigned int IntEncodeDown(float x, unsigned int max, float qOff = 0.0f) { - return (unsigned int)clip(floor(x * float(max) + qOff), 0.0f, float(max)); + // NB: Deliberately using `std::floor(float)` instead of `std::floorf(float)` + // to work around GCC Bug 89279. + return (unsigned int)clip(std::floor(x * float(max) + qOff), 0.0f, float(max)); } /// Linear encoding function rounding to nearest. @@ -179,29 +183,7 @@ inline unsigned int IntEncode(float x, unsigned int max, float qOff, float& err) /// @param[in] qOff Offset to add before quantization. /// @param[in,out] err Quantization error (including effects due to adding qOff). /// -inline unsigned int IntEncode(const GammaCurvePtr& g, float x, unsigned int max, float qOff, float& err) -{ - if (GammaCurve::IsNeutral(g)) - return IntEncode(x, max, qOff, err); - - float xEff = clip(x, 0.0f, 1.0f) + err; - unsigned int v = IntEncodeDown(GammaCurve::Encode(g, xEff), max); - float decoded = IntDecode(g, v, max); - if (v >= max) - { - err = xEff - decoded; - return v; - } - float decodedUp = IntDecode(g, v + 1, max); - float threshold = (0.5 - qOff) * decoded + (0.5 + qOff) * decodedUp; - if (xEff > threshold) - { - decoded = decodedUp; - ++v; - } - err = xEff - decoded; - return v; -} +unsigned int IntEncode(const GammaCurvePtr& g, float x, unsigned int max, float qOff, float& err); /// Generic encoding function. /// @@ -321,5 +303,6 @@ void GetEncodedRGBValue(const Image* img, unsigned int x, unsigned int y, const //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_IMAGE_ENCODING_H diff --git a/source/base/image/gif.cpp b/source/base/image/gif.cpp index dab308dba..cc0a3df32 100644 --- a/source/base/image/gif.cpp +++ b/source/base/image/gif.cpp @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -50,9 +50,18 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/gif.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" + // this must be the last file included #include "base/povdebug.h" @@ -63,15 +72,15 @@ namespace Gif { // TODO: make sure we don't leak an image object if we throw an exception. -Image *Read (IStream *file, const Image::ReadOptions& options, bool IsPOTFile) +Image *Read (IStream *file, const ImageReadOptions& options, bool IsPOTFile) { - int data ; - int width; - int height; - Image *image = nullptr; - unsigned char buffer[256]; - vector colormap ; - int alphaIdx = -1; // assume no transparency color + int data; + int width; + int height; + Image* image = nullptr; + unsigned char buffer[256]; + std::vector colormap; + int alphaIdx = -1; // assume no transparency color // GIF files used to have no clearly defined gamma by default, but a W3C recommendation exists for them to use sRGB. // Anyway, use whatever the user has chosen as default. @@ -173,7 +182,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options, bool IsPOTFile) width = (int) buffer[4] | ((int) buffer[5] << 8); height = (int) buffer[6] | ((int) buffer[7] << 8); - image = Image::Create (width, height, Image::Colour_Map, colormap) ; + image = Image::Create (width, height, ImageDataType::Colour_Map, colormap) ; // [CLi] GIF only uses full opacity or full transparency, so premultiplied vs. non-premultiplied alpha is not an issue /* Get bytes */ @@ -201,7 +210,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options, bool IsPOTFile) if ((width & 0x01) != 0) throw POV_EXCEPTION(kFileDataErr, "Invalid width for POT file"); int newWidth = width / 2 ; - Image *newImage = Image::Create (newWidth, height, Image::Gray_Int16) ; + Image *newImage = Image::Create (newWidth, height, ImageDataType::Gray_Int16) ; for (int y = 0 ; y < height ; y++) for (int x = 0 ; x < newWidth ; x++) newImage->SetGrayValue (x, y, (unsigned int) image->GetIndexedValue (x, y) << 8 | image->GetIndexedValue (x + newWidth, y)) ; @@ -211,7 +220,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options, bool IsPOTFile) return (newImage) ; } -} // end of namespace Gif +} +// end of namespace Gif } +// end of namespace pov_base diff --git a/source/base/image/gif.h b/source/base/image/gif.h index cb33f1c46..717dc10d0 100644 --- a/source/base/image/gif.h +++ b/source/base/image/gif.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,15 +60,17 @@ namespace pov_base namespace Gif { -Image *Read(IStream *file, const Image::ReadOptions& options, bool IsPOTFile); +Image *Read(IStream *file, const ImageReadOptions& options, bool IsPOTFile); void Decode(IStream *file, Image *image); } +// end of namespace Gif /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_GIF_H diff --git a/source/base/image/gifdecod.cpp b/source/base/image/gifdecod.cpp index 86414da4c..c71d7957e 100644 --- a/source/base/image/gifdecod.cpp +++ b/source/base/image/gifdecod.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -61,8 +61,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/gif.h" -// Boost header files -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/pov_err.h" +#include "base/image/image.h" // this must be the last file included #include "base/povdebug.h" @@ -111,7 +119,7 @@ namespace Gif 0x07FF, 0x0FFF }; - typedef struct + struct Param_Block final { short curr_size; /* The current code size */ short clear_code; /* Value for a clear code */ @@ -124,7 +132,7 @@ namespace Gif UTINY b1; /* Current byte */ UTINY byte_buff[257]; /* Current block */ UTINY *pbytes; /* Pointer to next byte in block */ - } Param_Block ; + }; /* get_next_code() * - gets the next code from the GIF file. Returns the code, or else @@ -255,10 +263,10 @@ namespace Gif params.slot = params.newcodes = params.ending + 1; params.navail_bytes = params.nbits_left = 0; - boost::scoped_array dstack (new UTINY [MAX_CODES + 1]); - boost::scoped_array suffix (new UTINY [MAX_CODES + 1]); - boost::scoped_array prefix (new UWORD [MAX_CODES + 1]); - boost::scoped_array buf (new UTINY [width]); + std::unique_ptr dstack (new UTINY [MAX_CODES + 1]); + std::unique_ptr suffix (new UTINY [MAX_CODES + 1]); + std::unique_ptr prefix (new UWORD [MAX_CODES + 1]); + std::unique_ptr buf (new UTINY [width]); /* Initialize in case they forgot to put in a clear code. * (This shouldn't happen, but we'll try and decode it anyway...) @@ -404,5 +412,7 @@ namespace Gif } } +// end of namespace Gif } +// end of namespace pov_base diff --git a/source/base/image/hdr.cpp b/source/base/image/hdr.cpp index cc56c0047..ba29ee6a8 100644 --- a/source/base/image/hdr.cpp +++ b/source/base/image/hdr.cpp @@ -13,7 +13,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,14 +41,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/hdr.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include // POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/types.h" +#include "base/image/colourspace.h" #include "base/image/dither.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -72,12 +77,6 @@ namespace HDR * Local typedefs ******************************************************************************/ -struct Messages -{ - vector warnings; - string error; -}; - typedef unsigned char RGBE[4]; // red, green, blue, exponent void GetRGBE(RGBE rgbe, const Image *image, int col, int row, const GammaCurvePtr& gamma, DitherStrategy& dither); @@ -157,7 +156,7 @@ void ReadOldLine(unsigned char *scanline, int width, IStream *file) } } -Image *Read(IStream *file, const Image::ReadOptions& options) +Image *Read(IStream *file, const ImageReadOptions& options) { char line[2048]; char *s; @@ -170,7 +169,7 @@ Image *Read(IStream *file, const Image::ReadOptions& options) unsigned int width; unsigned int height; Image *image = nullptr; - Image::ImageDataType imagetype = options.itype; + ImageDataType imagetype = options.itype; // Radiance HDR files store linear color values by default, so never convert unless the user overrides // (e.g. to handle a non-compliant file). @@ -202,8 +201,8 @@ Image *Read(IStream *file, const Image::ReadOptions& options) if(sscanf(line, "%2[+-XY] %u %2[+-XY] %u\n", s1, &height, s2, &width) != 4) throw POV_EXCEPTION(kFileDataErr, "Bad HDR file header"); - if(imagetype == Image::Undefined) - imagetype = Image::RGBFT_Float; + if(imagetype == ImageDataType::Undefined) + imagetype = ImageDataType::RGBFT_Float; // TODO - A dedicated RGB_Float container would be more space efficient. image = Image::Create(width, height, imagetype); // NB: HDR files don't use alpha, so premultiplied vs. non-premultiplied is not an issue @@ -287,7 +286,7 @@ Image *Read(IStream *file, const Image::ReadOptions& options) return image; } -void Write(OStream *file, const Image *image, const Image::WriteOptions& options) +void Write(OStream *file, const Image *image, const ImageWriteOptions& options) { int width = image->GetWidth(); int height = image->GetHeight(); @@ -409,7 +408,8 @@ void Write(OStream *file, const Image *image, const Image::WriteOptions& options } } -} // end of namespace HDR - -} // end of namespace pov_base +} +// end of namespace HDR +} +// end of namespace pov_base diff --git a/source/base/image/hdr.h b/source/base/image/hdr.h index c291a2aa9..b1b6f7bae 100644 --- a/source/base/image/hdr.h +++ b/source/base/image/hdr.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,15 +60,17 @@ namespace HDR /// /// @{ -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace HDR } +// end of namespace pov_base #endif // POVRAY_BASE_HDR_H diff --git a/source/base/image/iff.cpp b/source/base/image/iff.cpp index 48e739411..0c2e0bf50 100644 --- a/source/base/image/iff.cpp +++ b/source/base/image/iff.cpp @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -37,11 +37,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/iff.h" -// Standard C++ header files +// C++ variants of C standard header files +#include + +// C++ standard header files +#include #include -// Boost header files -#include +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/image/image.h" // this must be the last file included #include "base/povdebug.h" @@ -70,11 +75,13 @@ namespace Iff * Type definitions ******************************************************************************/ -typedef struct Chunk_Header_Struct +struct Chunk_Header_Struct final { - int name; - int size; -} CHUNK_HEADER ; + std::int_fast32_t name; + std::int_fast32_t size; +}; + +using CHUNK_HEADER = Chunk_Header_Struct; ///< @deprecated /***************************************************************************** * Static functions @@ -96,15 +103,15 @@ static int read_word(IStream *file) return (result); } -static long read_long(IStream *file) +static std::int_fast32_t read_long(IStream *file) { - long result = 0; + std::int_fast32_t result = 0; for (int i = 0; i < 4; i++) result = (result << 8) + read_byte(file); return (result); } -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { int nPlanes = 0; int compression = 0; @@ -123,16 +130,16 @@ Image *Read (IStream *file, const Image::ReadOptions& options) unsigned int r; unsigned int g; unsigned int b; - unsigned long creg; + std::uint_fast32_t creg; Image::RGBMapEntry entry; - vector colormap; + std::vector colormap; while (true) { Chunk_Header.name = read_long(file); Chunk_Header.size = read_long(file); - switch (IFF_SWITCH_CAST Chunk_Header.name) + switch (Chunk_Header.name) { case FORM: if (read_long(file) != ILBM) @@ -179,7 +186,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) // TODO FIXME - gamma! } - for (int i = colourmap_size * 3; (long)i < Chunk_Header.size; i++) + for (std::int_fast32_t i = colourmap_size * 3; i < Chunk_Header.size; i++) read_byte(file); break; @@ -187,9 +194,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options) case BODY: if (width > 0 && height > 0) { - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = ((viewmodes & HAM) != 0 || nPlanes == 24) ? Image::RGB_Int8 : Image::Colour_Map; + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = ((viewmodes & HAM) != 0 || nPlanes == 24) ? ImageDataType::RGB_Int8 : ImageDataType::Colour_Map; if ((viewmodes & HAM) != 0 || nPlanes == 24) image = Image::Create (width, height, imagetype); else @@ -197,7 +204,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) // NB: IFF-ILBM files don't use alpha, so premultiplied vs. non-premultiplied is not an issue int rowlen = ((width + 15) / 16) * 2 ; - boost::scoped_array row_bytes (new unsigned char [nPlanes * rowlen]); + std::unique_ptr row_bytes (new unsigned char [nPlanes * rowlen]); for (int row = 0; row < height; row++) { @@ -312,7 +319,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) break; default: - for (int i = 0; (long)i < Chunk_Header.size; i++) + for (std::int_fast32_t i = 0; i < Chunk_Header.size; i++) if (file->Read_Byte() == EOF) throw POV_EXCEPTION(kFileDataErr, "Unexpected EOF while reading IFF-ILBM file"); break; @@ -321,7 +328,8 @@ Image *Read (IStream *file, const Image::ReadOptions& options) return (image); } -} // end of namespace Iff - } +// end of namespace Iff +} +// end of namespace pov_base diff --git a/source/base/image/iff.h b/source/base/image/iff.h index b958e2241..554131e3b 100644 --- a/source/base/image/iff.h +++ b/source/base/image/iff.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,14 +60,16 @@ namespace Iff /// /// @{ -Image *Read(IStream *file, const Image::ReadOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace Iff } +// end of namespace pov_base #endif // POVRAY_BASE_IFF_H diff --git a/source/base/image/image.cpp b/source/base/image/image.cpp index 3418aff79..42d331f9f 100644 --- a/source/base/image/image.cpp +++ b/source/base/image/image.cpp @@ -36,20 +36,28 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/image.h" -// Standard C++ header files -#include -#include +// C++ variants of C standard header files +#include -// Standard POSIX header files +// C++ standard header files +// (none at the moment) + +// POSIX standard header files +// TODO FIXME - Any POSIX-specific stuff should be considered platform-specific. #include #include #include // POV-Ray header files (base module) +#include "base/filesystem.h" #include "base/platformbase.h" +#include "base/povassert.h" #include "base/safemath.h" +#include "base/stringutilities.h" #include "base/image/bmp.h" +#include "base/image/colourspace.h" #include "base/image/dither.h" +#include "base/image/encoding.h" #include "base/image/gif.h" #include "base/image/hdr.h" #include "base/image/iff.h" @@ -78,82 +86,93 @@ namespace pov_base { using std::allocator; +using std::min; +using std::max; +using std::vector; -Image::WriteOptions::WriteOptions() : +ImageWriteOptions::ImageWriteOptions() : ditherStrategy(GetNoOpDitherStrategy()), offset_x(0), offset_y(0), - alphaMode(kAlphaMode_None), + alphaMode(ImageAlphaMode::None), bitsPerChannel(8), compression(-1), grayscale(false) {} -template > -class BitMapImage : public Image +GammaCurvePtr ImageWriteOptions::GetTranscodingGammaCurve(GammaCurvePtr defaultEncodingGamma) const +{ + if (encodingGamma) + return TranscodingGammaCurve::Get(workingGamma, encodingGamma); + else + return TranscodingGammaCurve::Get(workingGamma, defaultEncodingGamma); +} + +template> +class BitMapImage final : public Image { public: BitMapImage(unsigned int w, unsigned int h) : - Image(w, h, Bit_Map) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + Image(w, h, ImageDataType::Bit_Map) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } BitMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + Image(w, h, ImageDataType::Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } BitMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + Image(w, h, ImageDataType::Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } BitMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } - ~BitMapImage() { } + Image(w, h, ImageDataType::Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + virtual ~BitMapImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return true; } - bool IsColour() const + virtual bool IsColour() const override { return false; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return 1; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return pixels[x + y * size_t(width)]; } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); if(pixels[x + y * size_t(width)] == true) @@ -161,143 +180,143 @@ class BitMapImage : public Image else return 0.0f; } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { gray = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { red = green = blue = GetGrayValue(x, y); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { red = green = blue = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { red = green = blue = GetGrayValue(x, y); transm = FT_OPAQUE; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { red = green = blue = GetGrayValue(x, y); filter = transm = FT_OPAQUE; } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = bit; } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = (gray != 0.0f); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = (gray != 0); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = (gray != 0.0f); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = (gray != 0); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = IS_NONZERO_RGB(red, green, blue); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = IS_NONZERO_RGB_INT(red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, red, green, blue); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { fill(pixels.begin(), pixels.end(), bit); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillBitValue(gray != 0.0f); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillBitValue(gray != 0); } - void FillGrayAValue(float gray, float) + virtual void FillGrayAValue(float gray, float) override { FillBitValue(gray != 0.0f); } - void FillGrayAValue(unsigned int gray, unsigned int) + virtual void FillGrayAValue(unsigned int gray, unsigned int) override { FillBitValue(gray != 0); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillBitValue(IS_NONZERO_RGB(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillBitValue(IS_NONZERO_RGB_INT(red, green, blue)); } - void FillRGBAValue(float red, float green, float blue, float) + virtual void FillRGBAValue(float red, float green, float blue, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. FillRGBValue(red, green, blue); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. FillRGBValue(red, green, blue); } - void FillRGBTValue(float red, float green, float blue, float) + virtual void FillRGBTValue(float red, float green, float blue, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. FillRGBValue(red, green, blue); } - void FillRGBFTValue(float red, float green, float blue, float, float) + virtual void FillRGBFTValue(float red, float green, float blue, float, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. FillRGBValue(red, green, blue); @@ -308,19 +327,19 @@ class BitMapImage : public Image typedef BitMapImage<> MemoryBitMapImage; -template > -class ColourMapImage : public Image +template> +class ColourMapImage final : public Image { public: ColourMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + Image(w, h, ImageDataType::Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } ColourMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + Image(w, h, ImageDataType::Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } ColourMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } - ~ColourMapImage() { } + Image(w, h, ImageDataType::Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + virtual ~ColourMapImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { if((colormaptype != RGBAColourMap) && (colormaptype != RGBFTColourMap)) return true; @@ -359,48 +378,48 @@ class ColourMapImage : public Image return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return true; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return (colormaptype == RGBAColourMap); } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return (colormaptype == RGBFTColourMap); } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return 255; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { float red, green, blue, filter, transm, alpha; switch(colormaptype) @@ -420,7 +439,7 @@ class ColourMapImage : public Image return false; } } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue, filter, transm, alpha; switch(colormaptype) @@ -438,7 +457,7 @@ class ColourMapImage : public Image return 0.0f; } } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { float red, green, blue, filter, transm; alpha = ALPHA_OPAQUE; // (unless noted otherwise) @@ -462,7 +481,7 @@ class ColourMapImage : public Image return; } } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { CHECK_BOUNDS(x, y); MapEntry e(colormap[pixels[x + y * size_t(width)]]); @@ -470,7 +489,7 @@ class ColourMapImage : public Image green = e.green; blue = e.blue; } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { CHECK_BOUNDS(x, y); MapEntry e(colormap[pixels[x + y * size_t(width)]]); @@ -490,7 +509,7 @@ class ColourMapImage : public Image return; } } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { CHECK_BOUNDS(x, y); MapEntry e(colormap[pixels[x + y * size_t(width)]]); @@ -510,7 +529,7 @@ class ColourMapImage : public Image return; } } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { CHECK_BOUNDS(x, y); MapEntry e(colormap[pixels[x + y * size_t(width)]]); @@ -532,126 +551,126 @@ class ColourMapImage : public Image return; } } - unsigned char GetIndexedValue(unsigned int x, unsigned int y) + virtual unsigned char GetIndexedValue(unsigned int x, unsigned int y) override { CHECK_BOUNDS(x, y); return pixels[x + y * size_t(width)]; } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = Bit2Map(bit); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = Gray2Map(gray); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = Gray2Map(float(gray) / 255.0); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = GrayA2Map(gray, alpha); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = GrayA2Map(float(gray) / 255.0, float(alpha) / 255.0); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGB2Map(red, green, blue); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGB2Map(float(red) / 255.0, float(green) / 255.0, float(blue) / 255.0); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGBA2Map(red, green, blue, alpha); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGBA2Map(float(red) / 255.0, float(green) / 255.0, float(blue) / 255.0, float(alpha) / 255.0); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGBT2Map(red, green, blue, transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGBA2Map(col.red(), col.green(), col.blue(), col.alpha()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { CHECK_BOUNDS(x, y); // [CLi 2009-09] this was dividing by 255 - which I presume to have been a bug. pixels[x + y * size_t(width)] = RGBFT2Map(red, green, blue, filter, transm); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { CHECK_BOUNDS(x, y); // [CLi 2009-09] this was dividing by 255 - which I presume to have been a bug. pixels[x + y * size_t(width)] = RGBFT2Map(col.red(), col.green(), col.blue(), col.filter(), col.transm()); } - void SetIndexedValue(unsigned int x, unsigned int y, unsigned char index) + virtual void SetIndexedValue(unsigned int x, unsigned int y, unsigned char index) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = index; } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { fill(pixels.begin(), pixels.end(), Bit2Map(bit)); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { fill(pixels.begin(), pixels.end(), Gray2Map(gray)); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { fill(pixels.begin(), pixels.end(), Gray2Map(float(gray) / 255.0)); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { fill(pixels.begin(), pixels.end(), GrayA2Map(gray, alpha)); } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { fill(pixels.begin(), pixels.end(), GrayA2Map(float(gray) / 255.0, float(alpha) / 255.0)); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { fill(pixels.begin(), pixels.end(), RGB2Map(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { fill(pixels.begin(), pixels.end(), RGB2Map(float(red) / 255.0, float(green) / 255.0, float(blue) / 255.0)); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { fill(pixels.begin(), pixels.end(), RGBA2Map(red, green, blue, alpha)); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { fill(pixels.begin(), pixels.end(), RGBA2Map(float(red) / 255.0, float(green) / 255.0, float(blue) / 255.0, float(alpha) / 255.0)); } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { fill(pixels.begin(), pixels.end(), RGBT2Map(red, green, blue, transm)); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { // [CLi 2009-09] this was dividing by 255 - which I presume to have been a bug. fill(pixels.begin(), pixels.end(), RGBFT2Map(red, green, blue, filter, transm)); @@ -811,8 +830,8 @@ class ColourMapImage : public Image typedef ColourMapImage<> MemoryColourMapImage; -template > -class GrayImage : public Image +template> +class GrayImage final : public Image { public: GrayImage(unsigned int w, unsigned int h) : @@ -823,198 +842,198 @@ class GrayImage : public Image Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } GrayImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } - ~GrayImage() { } + virtual ~GrayImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return true; } - bool IsColour() const + virtual bool IsColour() const override { return false; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return (pixels[x + y * size_t(width)] != 0); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return float(pixels[x + y * size_t(width)]) / float(TMAX); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { CHECK_BOUNDS(x, y); gray = float(pixels[x + y * size_t(width)]) / float(TMAX); alpha = ALPHA_OPAQUE; } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { red = green = blue = GetGrayValue(x, y); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { red = green = blue = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { red = green = blue = GetGrayValue(x, y); transm = FT_OPAQUE; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { red = green = blue = GetGrayValue(x, y); filter = transm = FT_OPAQUE; } - unsigned char GetIndexedValue(unsigned int x, unsigned int y) + virtual unsigned char GetIndexedValue(unsigned int x, unsigned int y) override { CHECK_BOUNDS(x, y); return (unsigned char)(int(pixels[x + y * size_t(width)]) / ((TMAX + 1) >> 8)); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray * float(TMAX)); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray * float(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetGrayValue(x, y, RGB2Gray(red, green, blue)); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetGrayValue(x, y, RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX))); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue((unsigned int)(gray * float(TMAX))); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { fill(pixels.begin(), pixels.end(), T(gray)); } - void FillGrayAValue(float gray, float) + virtual void FillGrayAValue(float gray, float) override { FillGrayValue(gray); } - void FillGrayAValue(unsigned int gray, unsigned int) + virtual void FillGrayAValue(unsigned int gray, unsigned int) override { FillGrayValue(gray); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillGrayValue(RGB2Gray(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillGrayValue(RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX))); } - void FillRGBAValue(float red, float green, float blue, float) + virtual void FillRGBAValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { FillRGBValue(red, green, blue); } - void FillRGBTValue(float red, float green, float blue, float) + virtual void FillRGBTValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBFTValue(float red, float green, float blue, float, float) + virtual void FillRGBFTValue(float red, float green, float blue, float, float) override { FillRGBValue(red, green, blue); } @@ -1022,12 +1041,12 @@ class GrayImage : public Image vector pixels; }; -typedef GrayImage MemoryGray8Image; +typedef GrayImage MemoryGray8Image; -typedef GrayImage MemoryGray16Image; +typedef GrayImage MemoryGray16Image; -template > -class GrayAImage : public Image +template> +class GrayAImage final : public Image { public: GrayAImage(unsigned int w, unsigned int h) : @@ -1038,9 +1057,9 @@ class GrayAImage : public Image Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 2u)); FillBitValue(false); } GrayAImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 2u)); FillBitValue(false); } - ~GrayAImage() { } + virtual ~GrayAImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { for(typename vector::const_iterator i(pixels.begin()); i != pixels.end(); i += 2) { @@ -1050,81 +1069,81 @@ class GrayAImage : public Image return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return true; } - bool IsColour() const + virtual bool IsColour() const override { return false; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return true; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. CHECK_BOUNDS(x, y); return (pixels[(x + y * size_t(width)) * 2] != 0); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return float(pixels[(x + y * size_t(width)) * 2]) / float(TMAX); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { CHECK_BOUNDS(x, y); gray = float(pixels[(x + y * size_t(width)) * 2]) / float(TMAX); alpha = float(pixels[(x + y * size_t(width)) * 2 + 1]) / float(TMAX); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { red = green = blue = GetGrayValue(x, y); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { GetGrayAValue(x, y, red, alpha); green = blue = red; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float alpha; GetGrayAValue(x, y, red, alpha); green = blue = red; transm = 1.0 - alpha; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { float alpha; GetGrayAValue(x, y, red, alpha); @@ -1132,83 +1151,83 @@ class GrayAImage : public Image RGBFTColour::AtoFT(alpha, filter, transm); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayAValue(x, y, TMAX, ALPHA_OPAQUE_INT(TMAX)); else SetGrayAValue(x, y, (unsigned int)0, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetGrayAValue(x, y, gray, ALPHA_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetGrayAValue(x, y, gray, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 2] = T(gray * float(TMAX)); pixels[(x + y * size_t(width)) * 2 + 1] = T(alpha * float(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 2] = gray; pixels[(x + y * size_t(width)) * 2 + 1] = alpha; } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetGrayValue(x, y, RGB2Gray(red, green, blue)); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetGrayValue(x, y, RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX))); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), alpha); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // TODO FIXME - this unnecessarily converts alpha from int to float, requiring it to be converted back to int SetGrayAValue(x, y, RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX)), float(alpha) / float(TMAX)); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), 1.0 - transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetGrayAValue(x, y, RGB2Gray(col.red(), col.green(), col.blue()), col.alpha()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), RGBFTColour::FTtoA(filter, transm)); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetGrayAValue(x, y, RGB2Gray(col.red(), col.green(), col.blue()), col.FTtoA()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue((unsigned int)(gray * float(TMAX))); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillGrayAValue(gray, ALPHA_OPAQUE_INT(TMAX)); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T g(gray * float(TMAX)), a(alpha * float(TMAX)); @@ -1219,7 +1238,7 @@ class GrayAImage : public Image *i = a; } } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -1228,28 +1247,28 @@ class GrayAImage : public Image *i = T(alpha); } } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillGrayValue(RGB2Gray(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillGrayValue(RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX))); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { FillGrayAValue(RGB2Gray(red, green, blue), alpha); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // TODO FIXME - this unnecessarily converts alpha from int to float, requiring it to be converted back to int FillGrayAValue(RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX)), float(alpha) / float(TMAX)); } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillGrayAValue(RGB2Gray(red, green, blue), 1.0 - transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { FillGrayAValue(RGB2Gray(red, green, blue), RGBFTColour::FTtoA(filter, transm)); } @@ -1257,12 +1276,12 @@ class GrayAImage : public Image vector pixels; }; -typedef GrayAImage MemoryGrayA8Image; +typedef GrayAImage MemoryGrayA8Image; -typedef GrayAImage MemoryGrayA16Image; +typedef GrayAImage MemoryGrayA16Image; -template > -class RGBImage : public Image +template> +class RGBImage final : public Image { public: RGBImage(unsigned int w, unsigned int h) : @@ -1273,188 +1292,188 @@ class RGBImage : public Image Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 3u)); FillBitValue(false); } RGBImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 3u)); FillBitValue(false); } - ~RGBImage() { } + virtual ~RGBImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { float red, green, blue; GetRGBValue(x, y, red, green, blue); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue; GetRGBValue(x, y, red, green, blue); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { gray = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { CHECK_BOUNDS(x, y); red = float(pixels[(x + y * size_t(width)) * 3]) / float(TMAX); green = float(pixels[(x + y * size_t(width)) * 3 + 1]) / float(TMAX); blue = float(pixels[(x + y * size_t(width)) * 3 + 2]) / float(TMAX); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { GetRGBValue(x, y, red, green, blue); alpha = ALPHA_OPAQUE; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { GetRGBValue(x, y, red, green, blue); transm = FT_OPAQUE; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { GetRGBValue(x, y, red, green, blue); filter = transm = FT_OPAQUE; } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBValue(x, y, gray, gray, gray); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = gray; } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = T(gray * float(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = gray; } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 3] = T(red * float(TMAX)); pixels[(x + y * size_t(width)) * 3 + 1] = T(green * float(TMAX)); pixels[(x + y * size_t(width)) * 3 + 2] = T(blue * float(TMAX)); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 3] = T(red); pixels[(x + y * size_t(width)) * 3 + 1] = T(green); pixels[(x + y * size_t(width)) * 3 + 2] = T(blue); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue((unsigned int)(gray * float(TMAX))); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { fill(pixels.begin(), pixels.end(), gray); } - void FillGrayAValue(float gray, float) + virtual void FillGrayAValue(float gray, float) override { FillRGBValue(gray, gray, gray); } - void FillGrayAValue(unsigned int gray, unsigned int) + virtual void FillGrayAValue(unsigned int gray, unsigned int) override { FillRGBValue(gray, gray, gray); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T r(red * float(TMAX)), g(green * float(TMAX)), b(blue * float(TMAX)); @@ -1467,7 +1486,7 @@ class RGBImage : public Image *i = b; } } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -1478,19 +1497,19 @@ class RGBImage : public Image *i = T(blue); } } - void FillRGBAValue(float red, float green, float blue, float) + virtual void FillRGBAValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { FillRGBValue(red, green, blue); } - void FillRGBTValue(float red, float green, float blue, float) + virtual void FillRGBTValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBFTValue(float red, float green, float blue, float, float) + virtual void FillRGBFTValue(float red, float green, float blue, float, float) override { FillRGBValue(red, green, blue); } @@ -1498,12 +1517,12 @@ class RGBImage : public Image vector pixels; }; -typedef RGBImage MemoryRGB8Image; +typedef RGBImage MemoryRGB8Image; -typedef RGBImage MemoryRGB16Image; +typedef RGBImage MemoryRGB16Image; -template > -class RGBAImage : public Image +template> +class RGBAImage final : public Image { public: RGBAImage(unsigned int w, unsigned int h) : @@ -1514,9 +1533,9 @@ class RGBAImage : public Image Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 4u)); FillBitValue(false); } RGBAImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 4u)); FillBitValue(false); } - ~RGBAImage() { } + virtual ~RGBAImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { for(typename vector::const_iterator i(pixels.begin()); i != pixels.end(); i += 4) { @@ -1526,72 +1545,72 @@ class RGBAImage : public Image return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return true; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. float red, green, blue, alpha; GetRGBAValue(x, y, red, green, blue, alpha); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue, alpha; GetRGBAValue(x, y, red, green, blue, alpha); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { float red, green, blue; GetRGBAValue(x, y, red, green, blue, alpha); gray = RGB2Gray(red, green, blue); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { CHECK_BOUNDS(x, y); red = float(pixels[(x + y * size_t(width)) * 4]) / float(TMAX); @@ -1599,51 +1618,51 @@ class RGBAImage : public Image blue = float(pixels[(x + y * size_t(width)) * 4 + 2]) / float(TMAX); alpha = float(pixels[(x + y * size_t(width)) * 4 + 3]) / float(TMAX); } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); transm = 1.0 - alpha; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); RGBFTColour::AtoFT(alpha, filter, transm); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBAValue(x, y, gray, gray, gray, ALPHA_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetRGBAValue(x, y, gray, gray, gray, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { SetRGBAValue(x, y, gray, gray, gray, alpha); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { SetRGBAValue(x, y, gray, gray, gray, alpha); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetRGBAValue(x, y, red, green, blue, ALPHA_OPAQUE); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetRGBAValue(x, y, red, green, blue, ALPHA_OPAQUE_INT(TMAX)); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(red * float(TMAX)); @@ -1651,7 +1670,7 @@ class RGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(blue * float(TMAX)); pixels[(x + y * size_t(width)) * 4 + 3] = T(alpha * float(TMAX)); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(red); @@ -1659,11 +1678,11 @@ class RGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(blue); pixels[(x + y * size_t(width)) * 4 + 3] = T(alpha); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBAValue(x, y, red, green, blue, 1.0 - transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(col.red() * float(TMAX)); @@ -1671,11 +1690,11 @@ class RGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(col.blue() * float(TMAX)); pixels[(x + y * size_t(width)) * 4 + 3] = T(col.alpha() * float(TMAX)); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { SetRGBAValue(x, y, red, green, blue, RGBFTColour::FTtoA(filter, transm)); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(col.red() * float(TMAX)); @@ -1684,38 +1703,38 @@ class RGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 3] = T(col.FTtoA() * float(TMAX)); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillRGBAValue(gray, gray, gray, ALPHA_OPAQUE); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillRGBAValue(gray, gray, gray, ALPHA_OPAQUE_INT(TMAX)); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { FillRGBAValue(gray, gray, gray, alpha); } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { FillRGBAValue(gray, gray, gray, alpha); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillRGBAValue(red, green, blue, ALPHA_OPAQUE); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillRGBAValue(red, green, blue, ALPHA_OPAQUE_INT(TMAX)); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T r(red * float(TMAX)), g(green * float(TMAX)), b(blue * float(TMAX)), a(alpha * float(TMAX)); @@ -1730,7 +1749,7 @@ class RGBAImage : public Image *i = a; } } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -1743,11 +1762,11 @@ class RGBAImage : public Image *i = T(alpha); } } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillRGBAValue(red, green, blue, 1.0 - transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { FillRGBAValue(red, green, blue, RGBFTColour::FTtoA(filter, transm)); } @@ -1755,25 +1774,25 @@ class RGBAImage : public Image vector pixels; }; -typedef RGBAImage MemoryRGBA8Image; +typedef RGBAImage MemoryRGBA8Image; -typedef RGBAImage MemoryRGBA16Image; +typedef RGBAImage MemoryRGBA16Image; -template > > -class RGBFTImage : public Image +template>> +class RGBFTImage final : public Image { public: RGBFTImage(unsigned int w, unsigned int h) : - Image(w, h, RGBFT_Float) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } + Image(w, h, ImageDataType::RGBFT_Float) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } RGBFTImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } + Image(w, h, ImageDataType::RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } RGBFTImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } + Image(w, h, ImageDataType::RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } RGBFTImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } - ~RGBFTImage() { } + Image(w, h, ImageDataType::RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } + virtual ~RGBFTImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { for(typename PixelContainer::const_iterator i(pixels.begin()); i != pixels.end(); i += 5) { @@ -1782,85 +1801,85 @@ class RGBFTImage : public Image } return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return true; } - bool IsInt() const + virtual bool IsInt() const override { return false; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return true; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return 255; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); gray = RGB2Gray(red, green, blue); alpha = RGBFTColour::FTtoA(filter, transm); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { float filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { float filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); alpha = RGBFTColour::FTtoA(filter, transm); } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float filter; GetRGBFTValue(x, y, red, green, blue, filter, transm); transm = 1.0 - RGBFTColour::FTtoA(filter, transm); } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { CHECK_BOUNDS(x, y); red = pixels[(x + y * size_t(width)) * 5]; @@ -1870,63 +1889,63 @@ class RGBFTImage : public Image transm = pixels[(x + y * size_t(width)) * 5 + 4]; } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, 1.0f); else SetGrayValue(x, y, 0.0f); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBFTValue(x, y, gray, gray, gray, FT_OPAQUE, FT_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetGrayValue(x, y, float(gray) / 255.0f); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); SetRGBFTValue(x, y, gray, gray, gray, filter, transm); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { float c = float(gray) / 255.0f; float filter, transm; RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); SetRGBFTValue(x, y, c, c, c, filter, transm); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetRGBFTValue(x, y, red, green, blue, FT_OPAQUE, FT_OPAQUE); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetRGBFTValue(x, y, float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, FT_OPAQUE, FT_OPAQUE); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); SetRGBFTValue(x, y, red, green, blue, filter, transm); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { float filter, transm; RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); SetRGBFTValue(x, y, float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, filter, transm); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBFTValue(x, y, red, green, blue, FT_OPAQUE, transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBFTValue(x, y, col.red(), col.green(), col.blue(), FT_OPAQUE, col.transm()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 5] = red; @@ -1935,7 +1954,7 @@ class RGBFTImage : public Image pixels[(x + y * size_t(width)) * 5 + 3] = filter; pixels[(x + y * size_t(width)) * 5 + 4] = transm; } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 5] = col.red(); @@ -1945,56 +1964,56 @@ class RGBFTImage : public Image pixels[(x + y * size_t(width)) * 5 + 4] = col.transm(); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(1.0f); else FillGrayValue(0.0f); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillRGBFTValue(gray, gray, gray, FT_OPAQUE, FT_OPAQUE); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillGrayValue(float(gray) / 255.0f); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); FillRGBFTValue(gray, gray, gray, filter, transm); } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { FillGrayAValue(float(gray) / 255.0f, float(alpha) / 255.0f); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillRGBFTValue(red, green, blue, FT_OPAQUE, FT_OPAQUE); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillRGBFTValue(float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, FT_OPAQUE, FT_OPAQUE); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); FillRGBFTValue(red, green, blue, filter, transm); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { float filter, transm; RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); FillRGBFTValue(float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, filter, transm); } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillRGBFTValue(red, green, blue, FT_OPAQUE, transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { for(typename PixelContainer::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -2015,8 +2034,8 @@ class RGBFTImage : public Image typedef RGBFTImage<> MemoryRGBFTImage; -template > -class NonlinearGrayImage : public Image +template> +class NonlinearGrayImage final : public Image { public: NonlinearGrayImage(unsigned int w, unsigned int h) : @@ -2027,49 +2046,49 @@ class NonlinearGrayImage : public Image Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } NonlinearGrayImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } - ~NonlinearGrayImage() { } + virtual ~NonlinearGrayImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return true; } - bool IsColour() const + virtual bool IsColour() const override { return false; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return true; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) + virtual bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) override { if (max != TMAX) return false; if (!GammaCurve::IsNeutral(gamma)) return !g; @@ -2078,151 +2097,151 @@ class NonlinearGrayImage : public Image return true; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return (pixels[x + y * size_t(width)] != 0); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return gammaLUT[pixels[x + y * size_t(width)]]; } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { CHECK_BOUNDS(x, y); gray = gammaLUT[pixels[x + y * size_t(width)]]; alpha = ALPHA_OPAQUE; } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { red = green = blue = GetGrayValue(x, y); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { red = green = blue = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { red = green = blue = GetGrayValue(x, y); transm = FT_OPAQUE; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { red = green = blue = GetGrayValue(x, y); filter = transm = FT_OPAQUE; } - unsigned char GetIndexedValue(unsigned int x, unsigned int y) + virtual unsigned char GetIndexedValue(unsigned int x, unsigned int y) override { CHECK_BOUNDS(x, y); return (unsigned char)(int(pixels[x + y * size_t(width)]) / ((TMAX + 1) >> 8)); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = IntEncode(gamma, gray, TMAX); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = IntEncode(gamma, gray, TMAX); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetGrayValue(x, y, RGB2Gray(red, green, blue)); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetGrayValue(x, y, RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue])); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue(IntEncode(gamma, gray, TMAX)); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { fill(pixels.begin(), pixels.end(), T(gray)); } - void FillGrayAValue(float gray, float) + virtual void FillGrayAValue(float gray, float) override { FillGrayValue(gray); } - void FillGrayAValue(unsigned int gray, unsigned int) + virtual void FillGrayAValue(unsigned int gray, unsigned int) override { FillGrayValue(gray); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillGrayValue(RGB2Gray(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillGrayValue(RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue])); } - void FillRGBAValue(float red, float green, float blue, float) + virtual void FillRGBAValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { FillRGBValue(red, green, blue); } - void FillRGBTValue(float red, float green, float blue, float) + virtual void FillRGBTValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBFTValue(float red, float green, float blue, float, float) + virtual void FillRGBFTValue(float red, float green, float blue, float, float) override { FillRGBValue(red, green, blue); } @@ -2232,12 +2251,12 @@ class NonlinearGrayImage : public Image const float* gammaLUT; }; -typedef NonlinearGrayImage MemoryNonlinearGray8Image; +typedef NonlinearGrayImage MemoryNonlinearGray8Image; -typedef NonlinearGrayImage MemoryNonlinearGray16Image; +typedef NonlinearGrayImage MemoryNonlinearGray16Image; -template > -class NonlinearGrayAImage : public Image +template> +class NonlinearGrayAImage final : public Image { public: NonlinearGrayAImage(unsigned int w, unsigned int h) : @@ -2248,9 +2267,9 @@ class NonlinearGrayAImage : public Image Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 2u)); FillBitValue(false); } NonlinearGrayAImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 2u)); FillBitValue(false); } - ~NonlinearGrayAImage() { } + virtual ~NonlinearGrayAImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { for(typename vector::const_iterator i(pixels.begin()); i != pixels.end(); i += 2) { @@ -2260,43 +2279,43 @@ class NonlinearGrayAImage : public Image return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return true; } - bool IsColour() const + virtual bool IsColour() const override { return false; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return true; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return true; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) + virtual bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) override { if (max != TMAX) return false; if (!GammaCurve::IsNeutral(gamma)) return !g; @@ -2305,40 +2324,40 @@ class NonlinearGrayAImage : public Image return true; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. CHECK_BOUNDS(x, y); return (pixels[(x + y * size_t(width)) * 2] != 0); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return gammaLUT[pixels[(x + y * size_t(width)) * 2]]; } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { CHECK_BOUNDS(x, y); gray = gammaLUT[pixels[(x + y * size_t(width)) * 2]]; alpha = pixels[(x + y * size_t(width)) * 2 + 1] / float(TMAX); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { red = green = blue = GetGrayValue(x, y); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { GetGrayAValue(x, y, red, alpha); green = blue = red; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float alpha; GetGrayAValue(x, y, red, alpha); green = blue = red; transm = 1.0 - alpha; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { float alpha; GetGrayAValue(x, y, red, alpha); @@ -2346,85 +2365,85 @@ class NonlinearGrayAImage : public Image RGBFTColour::AtoFT(alpha, filter, transm); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayAValue(x, y, TMAX, ALPHA_OPAQUE_INT(TMAX)); else SetGrayAValue(x, y, (unsigned int)0, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetGrayAValue(x, y, gray, ALPHA_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetGrayAValue(x, y, gray, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 2] = IntEncode(gamma, gray, TMAX); pixels[(x + y * size_t(width)) * 2 + 1] = T(alpha * float(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 2] = gray; pixels[(x + y * size_t(width)) * 2 + 1] = alpha; } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetGrayValue(x, y, RGB2Gray(red, green, blue)); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { // not really pretty here, but we're doing color math, so we need to decode and re-encode SetGrayValue(x, y, RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue])); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), alpha); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // not really pretty here, but we're doing color math, so we need to decode and re-encode // TODO FIXME - this unnecessarily converts alpha from int to float, requiring it to be converted back to int SetGrayAValue(x, y, RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue]), float(alpha) / float(TMAX)); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), 1.0 - transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetGrayAValue(x, y, RGB2Gray(col.red(), col.green(), col.blue()), col.alpha()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), RGBFTColour::FTtoA(filter, transm)); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetGrayAValue(x, y, RGB2Gray(col.red(), col.green(), col.blue()), col.FTtoA()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue(IntEncode(gamma, gray, TMAX)); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillGrayAValue(gray, ALPHA_OPAQUE_INT(TMAX)); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T g(IntEncode(gamma, gray, TMAX)), a(IntEncode(alpha, TMAX)); @@ -2435,7 +2454,7 @@ class NonlinearGrayAImage : public Image *i = a; } } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -2444,30 +2463,30 @@ class NonlinearGrayAImage : public Image *i = T(alpha); } } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillGrayValue(RGB2Gray(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { // not really pretty here, but we're doing color math, so we need to decode and re-encode FillGrayValue(RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue])); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { FillGrayAValue(RGB2Gray(red, green, blue), alpha); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // not really pretty here, but we're doing color math, so we need to decode and re-encode // TODO FIXME - this unnecessarily converts alpha from int to float, requiring it to be converted back to int FillGrayAValue(RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue]), float(alpha) / float(TMAX)); } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillGrayAValue(RGB2Gray(red, green, blue), 1.0 - transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { FillGrayAValue(RGB2Gray(red, green, blue), RGBFTColour::FTtoA(filter, transm)); } @@ -2477,12 +2496,12 @@ class NonlinearGrayAImage : public Image const float* gammaLUT; }; -typedef NonlinearGrayAImage MemoryNonlinearGrayA8Image; +typedef NonlinearGrayAImage MemoryNonlinearGrayA8Image; -typedef NonlinearGrayAImage MemoryNonlinearGrayA16Image; +typedef NonlinearGrayAImage MemoryNonlinearGrayA16Image; -template > -class NonlinearRGBImage : public Image +template> +class NonlinearRGBImage final : public Image { public: NonlinearRGBImage(unsigned int w, unsigned int h) : @@ -2493,49 +2512,49 @@ class NonlinearRGBImage : public Image Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 3u)); FillBitValue(false); } NonlinearRGBImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 3u)); FillBitValue(false); } - ~NonlinearRGBImage() { } + virtual ~NonlinearRGBImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return true; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) + virtual bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) override { if (max != TMAX) return false; if (!GammaCurve::IsNeutral(gamma)) return !g; @@ -2544,141 +2563,141 @@ class NonlinearRGBImage : public Image return true; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { float red, green, blue; GetRGBValue(x, y, red, green, blue); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue; GetRGBValue(x, y, red, green, blue); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { gray = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { CHECK_BOUNDS(x, y); red = gammaLUT[pixels[(x + y * size_t(width)) * 3]]; green = gammaLUT[pixels[(x + y * size_t(width)) * 3 + 1]]; blue = gammaLUT[pixels[(x + y * size_t(width)) * 3 + 2]]; } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { GetRGBValue(x, y, red, green, blue); alpha = ALPHA_OPAQUE; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { GetRGBValue(x, y, red, green, blue); transm = FT_OPAQUE; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { GetRGBValue(x, y, red, green, blue); filter = transm = FT_OPAQUE; } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBValue(x, y, gray, gray, gray); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = gray; } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = IntEncode(gamma, gray, TMAX); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = gray; } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 3] = IntEncode(gamma, red, TMAX); pixels[(x + y * size_t(width)) * 3 + 1] = IntEncode(gamma, green, TMAX); pixels[(x + y * size_t(width)) * 3 + 2] = IntEncode(gamma, blue, TMAX); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 3] = T(red); pixels[(x + y * size_t(width)) * 3 + 1] = T(green); pixels[(x + y * size_t(width)) * 3 + 2] = T(blue); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue((unsigned int)(IntEncode(gamma, gray, TMAX))); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { fill(pixels.begin(), pixels.end(), gray); } - void FillGrayAValue(float gray, float) + virtual void FillGrayAValue(float gray, float) override { FillRGBValue(gray, gray, gray); } - void FillGrayAValue(unsigned int gray, unsigned int) + virtual void FillGrayAValue(unsigned int gray, unsigned int) override { FillRGBValue(gray, gray, gray); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T r(IntEncode(gamma, red, TMAX)), g(IntEncode(gamma, green, TMAX)), b(IntEncode(gamma, blue, TMAX)); @@ -2691,7 +2710,7 @@ class NonlinearRGBImage : public Image *i = b; } } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -2702,19 +2721,19 @@ class NonlinearRGBImage : public Image *i = T(blue); } } - void FillRGBAValue(float red, float green, float blue, float) + virtual void FillRGBAValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { FillRGBValue(red, green, blue); } - void FillRGBTValue(float red, float green, float blue, float) + virtual void FillRGBTValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBFTValue(float red, float green, float blue, float, float) + virtual void FillRGBFTValue(float red, float green, float blue, float, float) override { FillRGBValue(red, green, blue); } @@ -2724,12 +2743,12 @@ class NonlinearRGBImage : public Image const float* gammaLUT; }; -typedef NonlinearRGBImage MemoryNonlinearRGB8Image; +typedef NonlinearRGBImage MemoryNonlinearRGB8Image; -typedef NonlinearRGBImage MemoryNonlinearRGB16Image; +typedef NonlinearRGBImage MemoryNonlinearRGB16Image; -template > -class NonlinearRGBAImage : public Image +template> +class NonlinearRGBAImage final : public Image { public: NonlinearRGBAImage(unsigned int w, unsigned int h) : @@ -2740,9 +2759,9 @@ class NonlinearRGBAImage : public Image Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 4u)); FillBitValue(false); } NonlinearRGBAImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 4u)); FillBitValue(false); } - ~NonlinearRGBAImage() { } + virtual ~NonlinearRGBAImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { for(typename vector::const_iterator i(pixels.begin()); i != pixels.end(); i += 4) { @@ -2752,43 +2771,43 @@ class NonlinearRGBAImage : public Image return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return true; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return true; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) + virtual bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) override { if (max != TMAX) return false; if (!GammaCurve::IsNeutral(gamma)) return !g; @@ -2797,31 +2816,31 @@ class NonlinearRGBAImage : public Image return true; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. float red, green, blue, alpha; GetRGBAValue(x, y, red, green, blue, alpha); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue, alpha; GetRGBAValue(x, y, red, green, blue, alpha); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { float red, green, blue; GetRGBAValue(x, y, red, green, blue, alpha); gray = RGB2Gray(red, green, blue); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { CHECK_BOUNDS(x, y); red = gammaLUT[pixels[(x + y * size_t(width)) * 4]]; @@ -2829,51 +2848,51 @@ class NonlinearRGBAImage : public Image blue = gammaLUT[pixels[(x + y * size_t(width)) * 4 + 2]]; alpha = float(pixels[(x + y * size_t(width)) * 4 + 3]) / float(TMAX); } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); transm = 1.0 - alpha; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); RGBFTColour::AtoFT(alpha, filter, transm); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBAValue(x, y, gray, gray, gray, ALPHA_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetRGBAValue(x, y, gray, gray, gray, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { SetRGBAValue(x, y, gray, gray, gray, alpha); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { SetRGBAValue(x, y, gray, gray, gray, alpha); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetRGBAValue(x, y, red, green, blue, ALPHA_OPAQUE); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetRGBAValue(x, y, red, green, blue, ALPHA_OPAQUE_INT(TMAX)); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(IntEncode(gamma, red, TMAX)); @@ -2881,7 +2900,7 @@ class NonlinearRGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(IntEncode(gamma, blue, TMAX)); pixels[(x + y * size_t(width)) * 4 + 3] = T(IntEncode( alpha, TMAX)); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(red); @@ -2889,11 +2908,11 @@ class NonlinearRGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(blue); pixels[(x + y * size_t(width)) * 4 + 3] = T(alpha); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBAValue(x, y, red, green, blue, 1.0 - transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(col.red()); @@ -2901,11 +2920,11 @@ class NonlinearRGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(col.blue()); pixels[(x + y * size_t(width)) * 4 + 3] = T(col.alpha()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { SetRGBAValue(x, y, red, green, blue, RGBFTColour::FTtoA(filter, transm)); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(col.red()); @@ -2914,38 +2933,38 @@ class NonlinearRGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 3] = T(col.FTtoA()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillRGBAValue(gray, gray, gray, ALPHA_OPAQUE); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillRGBAValue(gray, gray, gray, ALPHA_OPAQUE_INT(TMAX)); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { FillRGBAValue(gray, gray, gray, alpha); } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { FillRGBAValue(gray, gray, gray, alpha); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillRGBAValue(red, green, blue, ALPHA_OPAQUE); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillRGBAValue(red, green, blue, ALPHA_OPAQUE_INT(TMAX)); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T r(IntEncode(gamma, red, TMAX)), g(IntEncode(gamma, green, TMAX)), b(IntEncode(gamma, blue, TMAX)), a(IntEncode(alpha, TMAX)); @@ -2960,7 +2979,7 @@ class NonlinearRGBAImage : public Image *i = a; } } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -2973,11 +2992,11 @@ class NonlinearRGBAImage : public Image *i = T(alpha); } } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillRGBAValue(red, green, blue, 1.0 - transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { FillRGBAValue(red, green, blue, RGBFTColour::FTtoA(filter, transm)); } @@ -2987,9 +3006,9 @@ class NonlinearRGBAImage : public Image const float* gammaLUT; }; -typedef NonlinearRGBAImage MemoryNonlinearRGBA8Image; +typedef NonlinearRGBAImage MemoryNonlinearRGBA8Image; -typedef NonlinearRGBAImage MemoryNonlinearRGBA16Image; +typedef NonlinearRGBAImage MemoryNonlinearRGBA16Image; // sample basic file-based pixel container. not very efficient. // it is expected that for performance reasons, platforms will provide their own specific @@ -3014,7 +3033,7 @@ class FileBackedPixelContainer FILTER = 3, TRANSM = 4 }; - class pixel_type + class pixel_type final { public: pixel_type() @@ -3064,43 +3083,40 @@ class FileBackedPixelContainer }; FileBackedPixelContainer(size_type width, size_type height, size_type bs): - m_File(-1), m_Width(width), m_Height(height), m_xPos(0), m_yPos(0), m_Dirty(false), m_Path(PlatformBase::GetInstance().CreateTemporaryFile()) + m_Width(width), m_Height(height), m_xPos(0), m_yPos(0), m_Dirty(false), m_Path(PlatformBase::GetInstance().CreateTemporaryFile()) { - if ((m_File = open(UCS2toSysString(m_Path).c_str(), O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) == -1) + if (!m_File.CreateRW(m_Path)) throw POV_EXCEPTION(kCannotOpenFileErr, "Cannot open backing file for intermediate image storage."); m_Blocksize = bs; m_Buffer.resize(m_Blocksize); // write extra data to create the big file and help 3rd party reader - POV_OFF_T pos; + std::int_least64_t pos; // NB: The following use of SafeUnsignedProduct also safeguards later computations of // pixel positions within the file, as long as x and y coordinates are sane - pos = SafeUnsignedProduct(m_Width, m_Height); + pos = SafeUnsignedProduct(m_Width, m_Height); if ( pos% m_Blocksize) { /* issue: the block would overlap the end of file */ pos /= m_Blocksize; pos++; - pos = SafeUnsignedProduct(pos, m_Blocksize); + pos = SafeUnsignedProduct(pos, m_Blocksize); } /* else fine case: the boundary of block match the boundary of pixels in file */ - pos = SafeUnsignedProduct(pos, sizeof(pixel_type)); + pos = SafeUnsignedProduct(pos, sizeof(pixel_type)); size_type meta[3]; meta[0] = sizeof(pixel_type); meta[1] = m_Width; meta[2] = m_Height; - if (POV_LSEEK(m_File, pos, SEEK_SET) != pos) + if (!m_File.Seek(pos)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file write/seek failed at creation."); - if (write(m_File, &meta[0], (int) sizeof(size_type)*3) != (sizeof(size_type)*3)) + if (!m_File.Write(meta, sizeof(size_type)*3)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file write failed at creation."); // m_Committed.resize(width * height / m_Blocksize); } virtual ~FileBackedPixelContainer() { - if (m_File != -1) - { - Flush(); - close(m_File); - } + Flush(); + m_File.Close(); if (m_Path.empty() == false) { // if shutdown has been delayed, by the time we reach here, the platform base @@ -3205,10 +3221,10 @@ class FileBackedPixelContainer } protected: - int m_File; + Filesystem::LargeFile m_File; bool m_Dirty; size_type m_Blocksize; - POV_OFF_T m_CurrentBlock; + std::int_least64_t m_CurrentBlock; size_type m_Width; size_type m_Height; size_type m_xPos; @@ -3243,7 +3259,7 @@ class FileBackedPixelContainer void ReadPixel(size_type x, size_type y, pixel_type& pixel) { - POV_OFF_T pos, block = (y * (POV_OFF_T)(m_Width) + x) / m_Blocksize; + std::int_least64_t pos, block = (y * (std::int_least64_t)(m_Width) + x) / m_Blocksize; if (block != m_CurrentBlock) { WriteCurrentBlock(); @@ -3258,33 +3274,33 @@ class FileBackedPixelContainer #endif pos = block * sizeof(pixel_type) * m_Blocksize; int chunk = sizeof(pixel_type) * m_Blocksize; - if (POV_LSEEK(m_File, pos, SEEK_SET) != pos) + if (!m_File.Seek(pos)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file read/seek failed."); - int bytes = read(m_File, &m_Buffer[0], chunk); + int bytes = m_File.Read(m_Buffer.data(), chunk); if (bytes != (sizeof(pixel_type) * m_Blocksize)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file read failed."); m_CurrentBlock = block; } POV_IMAGE_ASSERT (m_Blocksize != 0); - memcpy(&pixel, m_Buffer[(y * (POV_OFF_T)(m_Width) + x) % m_Blocksize], sizeof(pixel)); + memcpy(&pixel, m_Buffer[(y * (std::int_least64_t)(m_Width) + x) % m_Blocksize], sizeof(pixel)); } #if 0 bool BlockCommitted(size_type x, size_type y) { - POV_OFF_T block = (y * POV_OFF_T(m_Width) + x) / m_Blocksize; + std::int_least64_t block = (y * std::int_least64_t(m_Width) + x) / m_Blocksize; return(m_Committed[block]); } #endif void WriteCurrentBlock() { - POV_OFF_T pos; + std::int_least64_t pos; if (m_Dirty) { pos = m_CurrentBlock * sizeof(pixel_type) * m_Blocksize; - if (POV_LSEEK(m_File, pos, SEEK_SET) != pos) + if (!m_File.Seek(pos)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file write/seek failed."); - if (write(m_File, &m_Buffer[0], (int) sizeof(pixel_type) * m_Blocksize) != (sizeof(pixel_type) * m_Blocksize)) + if (!m_File.Write(m_Buffer.data(), sizeof(pixel_type) * m_Blocksize)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file write failed."); // m_Committed[m_CurrentBlock] = true; m_Dirty = false; @@ -3296,101 +3312,101 @@ class FileBackedPixelContainer pixel_type dummy; ReadPixel(x, y, dummy); - memcpy(m_Buffer[(y * (POV_OFF_T)(m_Width) + x) % m_Blocksize], &pixel, sizeof(pixel)); + memcpy(m_Buffer[(y * (std::int_least64_t)(m_Width) + x) % m_Blocksize], &pixel, sizeof(pixel)); m_Dirty = true; } private: - // not available - FileBackedPixelContainer(void) {} + + FileBackedPixelContainer() = delete; }; -class FileRGBFTImage : public Image +class FileRGBFTImage final : public Image { public: typedef FileBackedPixelContainer::pixel_type pixel_type; - FileRGBFTImage(unsigned int w, unsigned int h, unsigned int bs): Image(w, h, RGBFT_Float), pixels(width, height, bs) { } - ~FileRGBFTImage() { } - - bool IsGrayscale() const { return false; } - bool IsColour() const { return true; } - bool IsFloat() const { return true; } - bool IsInt() const { return false; } - bool IsIndexed() const { return false; } - bool IsGammaEncoded() const { return false; } - bool HasAlphaChannel() const { return false; } - bool HasFilterTransmit() const { return true; } - unsigned int GetMaxIntValue() const { return 255; } + FileRGBFTImage(unsigned int w, unsigned int h, unsigned int bs): Image(w, h, ImageDataType::RGBFT_Float), pixels(width, height, bs) { } + virtual ~FileRGBFTImage() override { } + + virtual bool IsGrayscale() const override { return false; } + virtual bool IsColour() const override { return true; } + virtual bool IsFloat() const override { return true; } + virtual bool IsInt() const override { return false; } + virtual bool IsIndexed() const override { return false; } + virtual bool IsGammaEncoded() const override { return false; } + virtual bool HasAlphaChannel() const override { return false; } + virtual bool HasFilterTransmit() const override { return true; } + virtual unsigned int GetMaxIntValue() const override { return 255; } void SetEncodingGamma(GammaCurvePtr gamma) { ; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) { return false; } - bool IsOpaque() const { throw POV_EXCEPTION(kUncategorizedError, "Internal error: IsOpaque() not supported in FileRGBFTImage"); } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } + virtual bool IsOpaque() const override { throw POV_EXCEPTION(kUncategorizedError, "Internal error: IsOpaque() not supported in FileRGBFTImage"); } + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); gray = RGB2Gray(red, green, blue); alpha = RGBFTColour::FTtoA(filter, transm); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { float filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { float filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); alpha = RGBFTColour::FTtoA(filter, transm); } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float filter; GetRGBFTValue(x, y, red, green, blue, filter, transm); transm = 1.0 - RGBFTColour::FTtoA(filter, transm); } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { CHECK_BOUNDS(x, y); pixels.GetPixel(x, y, red, green, blue, filter, transm); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, 1.0f); else SetGrayValue(x, y, 0.0f); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBFTValue(x, y, gray, gray, gray, FT_OPAQUE, FT_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetGrayValue(x, y, float(gray) / 255.0f); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); SetRGBFTValue(x, y, gray, gray, gray, filter, transm); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float c = float(gray) / 255.0f; @@ -3398,101 +3414,101 @@ class FileRGBFTImage : public Image RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); SetRGBFTValue(x, y, c, c, c, filter, transm); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetRGBFTValue(x, y, red, green, blue, FT_OPAQUE, FT_OPAQUE); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetRGBFTValue(x, y, float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, FT_OPAQUE, FT_OPAQUE); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); SetRGBFTValue(x, y, red, green, blue, filter, transm); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); SetRGBFTValue(x, y, float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, filter, transm); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBFTValue(x, y, red, green, blue, FT_OPAQUE, transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBFTValue(x, y, col.red(), col.green(), col.blue(), FT_OPAQUE, col.transm()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { CHECK_BOUNDS(x, y); pixels.SetPixel(x, y, red, green, blue, filter, transm); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { CHECK_BOUNDS(x, y); pixels.SetPixel(x, y, col); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(1.0f); else FillGrayValue(0.0f); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillRGBFTValue(gray, gray, gray, FT_OPAQUE, FT_OPAQUE); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillGrayValue(float(gray) / 255.0f); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); FillRGBFTValue(gray, gray, gray, filter, transm); } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { // TODO - should alpha be converted to filter and transm? [trf] FillGrayAValue(float(gray) / 255.0f, float(alpha) / 255.0f); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillRGBFTValue(red, green, blue, FT_OPAQUE, FT_OPAQUE); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillRGBFTValue(float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, FT_OPAQUE, FT_OPAQUE); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); FillRGBFTValue(red, green, blue, filter, transm); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); FillRGBFTValue(float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, filter, transm); } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillRGBFTValue(red, green, blue, FT_OPAQUE, transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { pixels.Fill(red, green, blue, filter, transm); } @@ -3566,68 +3582,40 @@ void RGBFTMap2RGBAMap(const vector& m, vectorred, i->green, i->blue, RGBFTColour::FTtoA(i->filter, i->transm))); } -Image::ImageDataType Image::GetImageDataType (ImageChannelDataType channelType, ImageChannelLayout layout) +ImageDataType Image::GetImageDataType (int minBitsPerChannel, int colourChannels, int alphaChannels, bool linear) { - switch (layout) + struct { ImageDataType type; int bpc; int cc; int ac; bool lin; } kaImageDataModels[] = { + // Note: Entries differing only in bpc must be ordered low-bpc first! + { ImageDataType::Gray_Gamma8, 8, 1, 0, false }, + { ImageDataType::Gray_Gamma16, 16, 1, 0, false }, + { ImageDataType::Gray_Int8, 8, 1, 0, true }, + { ImageDataType::Gray_Int16, 16, 1, 0, true }, + { ImageDataType::GrayA_Gamma8, 8, 1, 1, false }, + { ImageDataType::GrayA_Gamma16, 16, 1, 1, false }, + { ImageDataType::GrayA_Int8, 8, 1, 1, true }, + { ImageDataType::GrayA_Int16, 16, 1, 1, true }, + { ImageDataType::RGB_Gamma8, 8, 3, 0, false }, + { ImageDataType::RGB_Gamma16, 16, 3, 0, false }, + { ImageDataType::RGB_Int8, 8, 3, 0, true }, + { ImageDataType::RGB_Int16, 16, 3, 0, true }, + { ImageDataType::RGBA_Gamma8, 8, 3, 1, false }, + { ImageDataType::RGBA_Gamma16, 16, 3, 1, false }, + { ImageDataType::RGBA_Int8, 8, 3, 1, true }, + { ImageDataType::RGBA_Int16, 16, 3, 1, true }, + }; + for (auto& model : kaImageDataModels) { - case kImageChannelLayout_Gray: - switch (channelType) - { - case kImageChannelDataType_Int8: return Image::Gray_Int8; - case kImageChannelDataType_Int16: return Image::Gray_Int16; - case kImageChannelDataType_Gamma8: return Image::Gray_Gamma8; - case kImageChannelDataType_Gamma16: return Image::Gray_Gamma16; - default: - POV_IMAGE_ASSERT(false); - break; - } - break; - - case kImageChannelLayout_GrayA: - switch (channelType) - { - case kImageChannelDataType_Int8: return Image::GrayA_Int8; - case kImageChannelDataType_Int16: return Image::GrayA_Int16; - case kImageChannelDataType_Gamma8: return Image::GrayA_Gamma8; - case kImageChannelDataType_Gamma16: return Image::GrayA_Gamma16; - default: - POV_IMAGE_ASSERT(false); - break; - } - break; - - case kImageChannelLayout_RGB: - switch (channelType) - { - case kImageChannelDataType_Int8: return Image::RGB_Int8; - case kImageChannelDataType_Int16: return Image::RGB_Int16; - case kImageChannelDataType_Gamma8: return Image::RGB_Gamma8; - case kImageChannelDataType_Gamma16: return Image::RGB_Gamma16; - default: - POV_IMAGE_ASSERT(false); - break; - } - break; - - case kImageChannelLayout_RGBA: - switch (channelType) - { - case kImageChannelDataType_Int8: return Image::RGBA_Int8; - case kImageChannelDataType_Int16: return Image::RGBA_Int16; - case kImageChannelDataType_Gamma8: return Image::RGBA_Gamma8; - case kImageChannelDataType_Gamma16: return Image::RGBA_Gamma16; - default: - POV_IMAGE_ASSERT(false); - break; - } - break; - - default: - POV_IMAGE_ASSERT(false); - break; + if ((model.bpc >= minBitsPerChannel) && (model.cc == colourChannels) && + (model.ac == alphaChannels) && (model.lin == linear)) + return model.type; } + POV_IMAGE_ASSERT(false); + return ImageDataType::Undefined; +} - return Image::Undefined; +ImageDataType Image::GetImageDataType(int bitsPerChannel, int colourChannels, bool alpha, GammaCurvePtr gamma) +{ + return GetImageDataType(bitsPerChannel, colourChannels, (alpha ? 1 : 0), GammaCurve::IsNeutral(gamma)); } Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, unsigned int maxRAMmbHint, unsigned int pixelsPerBlockHint) @@ -3636,44 +3624,44 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, unsigned i { switch(t) { - case Bit_Map: + case ImageDataType::Bit_Map: return new MemoryBitMapImage(w, h); - case Gray_Int8: + case ImageDataType::Gray_Int8: return new MemoryGray8Image(w, h); - case Gray_Int16: + case ImageDataType::Gray_Int16: return new MemoryGray16Image(w, h); - case GrayA_Int8: + case ImageDataType::GrayA_Int8: return new MemoryGrayA8Image(w, h); - case GrayA_Int16: + case ImageDataType::GrayA_Int16: return new MemoryGrayA16Image(w, h); - case RGB_Int8: + case ImageDataType::RGB_Int8: return new MemoryRGB8Image(w, h); - case RGB_Int16: + case ImageDataType::RGB_Int16: return new MemoryRGB16Image(w, h); - case RGBA_Int8: + case ImageDataType::RGBA_Int8: return new MemoryRGBA8Image (w, h); - case RGBA_Int16: + case ImageDataType::RGBA_Int16: return new MemoryRGBA16Image(w, h); - case RGBFT_Float: + case ImageDataType::RGBFT_Float: if (maxRAMmbHint > 0) if (SafeUnsignedProduct(w, h, sizeof(FileRGBFTImage::pixel_type)) / 1048576 > maxRAMmbHint) return new FileRGBFTImage(w, h, pixelsPerBlockHint); return new MemoryRGBFTImage(w, h); - case RGB_Gamma8: + case ImageDataType::RGB_Gamma8: return new MemoryNonlinearRGB8Image(w, h); - case RGB_Gamma16: + case ImageDataType::RGB_Gamma16: return new MemoryNonlinearRGB16Image(w, h); - case RGBA_Gamma8: + case ImageDataType::RGBA_Gamma8: return new MemoryNonlinearRGBA8Image (w, h); - case RGBA_Gamma16: + case ImageDataType::RGBA_Gamma16: return new MemoryNonlinearRGBA16Image(w, h); - case Gray_Gamma8: + case ImageDataType::Gray_Gamma8: return new MemoryNonlinearGray8Image(w, h); - case Gray_Gamma16: + case ImageDataType::Gray_Gamma16: return new MemoryNonlinearGray16Image(w, h); - case GrayA_Gamma8: + case ImageDataType::GrayA_Gamma8: return new MemoryNonlinearGrayA8Image(w, h); - case GrayA_Gamma16: + case ImageDataType::GrayA_Gamma16: return new MemoryNonlinearGrayA16Image(w, h); default: throw POV_EXCEPTION_STRING("Undefined image format in Image::Create"); @@ -3691,45 +3679,45 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, bool allow { switch(t) { - case Bit_Map: + case ImageDataType::Bit_Map: return new MemoryBitMapImage(w, h); - case Gray_Int8: + case ImageDataType::Gray_Int8: return new MemoryGray8Image(w, h); - case Gray_Int16: + case ImageDataType::Gray_Int16: return new MemoryGray16Image(w, h); - case GrayA_Int8: + case ImageDataType::GrayA_Int8: return new MemoryGrayA8Image(w, h); - case GrayA_Int16: + case ImageDataType::GrayA_Int16: return new MemoryGrayA16Image(w, h); - case RGB_Int8: + case ImageDataType::RGB_Int8: return new MemoryRGB8Image(w, h); - case RGB_Int16: + case ImageDataType::RGB_Int16: return new MemoryRGB16Image(w, h); - case RGBA_Int8: + case ImageDataType::RGBA_Int8: return new MemoryRGBA8Image (w, h); - case RGBA_Int16: + case ImageDataType::RGBA_Int16: return new MemoryRGBA16Image(w, h); - case RGBFT_Float: + case ImageDataType::RGBFT_Float: #ifdef FILE_MAPPED_IMAGE_ALLOCATOR if (allowFileBacking) - return new RGBFTImage >(w, h); + return new RGBFTImage>(w, h); #endif return new MemoryRGBFTImage(w, h); - case RGB_Gamma8: + case ImageDataType::RGB_Gamma8: return new MemoryNonlinearRGB8Image(w, h); - case RGB_Gamma16: + case ImageDataType::RGB_Gamma16: return new MemoryNonlinearRGB16Image(w, h); - case RGBA_Gamma8: + case ImageDataType::RGBA_Gamma8: return new MemoryNonlinearRGBA8Image (w, h); - case RGBA_Gamma16: + case ImageDataType::RGBA_Gamma16: return new MemoryNonlinearRGBA16Image(w, h); - case Gray_Gamma8: + case ImageDataType::Gray_Gamma8: return new MemoryNonlinearGray8Image(w, h); - case Gray_Gamma16: + case ImageDataType::Gray_Gamma16: return new MemoryNonlinearGray16Image(w, h); - case GrayA_Gamma8: + case ImageDataType::GrayA_Gamma8: return new MemoryNonlinearGrayA8Image(w, h); - case GrayA_Gamma16: + case ImageDataType::GrayA_Gamma16: return new MemoryNonlinearGrayA16Image(w, h); default: throw POV_EXCEPTION_STRING("Undefined image format in Image::Create"); @@ -3747,47 +3735,47 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, const vect { switch(t) { - case Bit_Map: + case ImageDataType::Bit_Map: return new MemoryBitMapImage(w, h, m); - case Colour_Map: + case ImageDataType::Colour_Map: return new MemoryColourMapImage(w, h, m); - case Gray_Int8: + case ImageDataType::Gray_Int8: return new MemoryGray8Image(w, h, m); - case Gray_Int16: + case ImageDataType::Gray_Int16: return new MemoryGray16Image(w, h, m); - case GrayA_Int8: + case ImageDataType::GrayA_Int8: return new MemoryGrayA8Image(w, h, m); - case GrayA_Int16: + case ImageDataType::GrayA_Int16: return new MemoryGrayA16Image(w, h, m); - case RGB_Int8: + case ImageDataType::RGB_Int8: return new MemoryRGB8Image(w, h, m); - case RGB_Int16: + case ImageDataType::RGB_Int16: return new MemoryRGB16Image(w, h, m); - case RGBA_Int8: + case ImageDataType::RGBA_Int8: return new MemoryRGBA8Image (w, h, m); - case RGBA_Int16: + case ImageDataType::RGBA_Int16: return new MemoryRGBA16Image(w, h, m); - case RGBFT_Float: + case ImageDataType::RGBFT_Float: #ifdef FILE_MAPPED_IMAGE_ALLOCATOR if (allowFileBacking) - return new RGBFTImage >(w, h, m); + return new RGBFTImage>(w, h, m); #endif return new MemoryRGBFTImage(w, h, m); - case RGB_Gamma8: + case ImageDataType::RGB_Gamma8: return new MemoryNonlinearRGB8Image(w, h, m); - case RGB_Gamma16: + case ImageDataType::RGB_Gamma16: return new MemoryNonlinearRGB16Image(w, h, m); - case RGBA_Gamma8: + case ImageDataType::RGBA_Gamma8: return new MemoryNonlinearRGBA8Image (w, h, m); - case RGBA_Gamma16: + case ImageDataType::RGBA_Gamma16: return new MemoryNonlinearRGBA16Image(w, h, m); - case Gray_Gamma8: + case ImageDataType::Gray_Gamma8: return new MemoryNonlinearGray8Image(w, h, m); - case Gray_Gamma16: + case ImageDataType::Gray_Gamma16: return new MemoryNonlinearGray16Image(w, h, m); - case GrayA_Gamma8: + case ImageDataType::GrayA_Gamma8: return new MemoryNonlinearGrayA8Image(w, h, m); - case GrayA_Gamma16: + case ImageDataType::GrayA_Gamma16: return new MemoryNonlinearGrayA16Image(w, h, m); default: throw POV_EXCEPTION_STRING("Image::Create Exception TODO"); // TODO FIXME WIP @@ -3805,47 +3793,47 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, const vect { switch(t) { - case Bit_Map: + case ImageDataType::Bit_Map: return new MemoryBitMapImage(w, h, m); - case Colour_Map: + case ImageDataType::Colour_Map: return new MemoryColourMapImage(w, h, m); - case Gray_Int8: + case ImageDataType::Gray_Int8: return new MemoryGray8Image(w, h, m); - case Gray_Int16: + case ImageDataType::Gray_Int16: return new MemoryGray16Image(w, h, m); - case GrayA_Int8: + case ImageDataType::GrayA_Int8: return new MemoryGrayA8Image(w, h, m); - case GrayA_Int16: + case ImageDataType::GrayA_Int16: return new MemoryGrayA16Image(w, h, m); - case RGB_Int8: + case ImageDataType::RGB_Int8: return new MemoryRGB8Image(w, h, m); - case RGB_Int16: + case ImageDataType::RGB_Int16: return new MemoryRGB16Image(w, h, m); - case RGBA_Int8: + case ImageDataType::RGBA_Int8: return new MemoryRGBA8Image (w, h, m); - case RGBA_Int16: + case ImageDataType::RGBA_Int16: return new MemoryRGBA16Image(w, h, m); - case RGBFT_Float: -#ifdef FILE_MAPPED_RGBFT_IMAGE_ALLOCATOR + case ImageDataType::RGBFT_Float: +#ifdef FILE_MAPPED_IMAGE_ALLOCATOR if (allowFileBacking) - return new RGBFTImage >(w, h, m); + return new RGBFTImage>(w, h, m); #endif return new MemoryRGBFTImage(w, h, m); - case RGB_Gamma8: + case ImageDataType::RGB_Gamma8: return new MemoryNonlinearRGB8Image(w, h, m); - case RGB_Gamma16: + case ImageDataType::RGB_Gamma16: return new MemoryNonlinearRGB16Image(w, h, m); - case RGBA_Gamma8: + case ImageDataType::RGBA_Gamma8: return new MemoryNonlinearRGBA8Image (w, h, m); - case RGBA_Gamma16: + case ImageDataType::RGBA_Gamma16: return new MemoryNonlinearRGBA16Image(w, h, m); - case Gray_Gamma8: + case ImageDataType::Gray_Gamma8: return new MemoryNonlinearGray8Image(w, h, m); - case Gray_Gamma16: + case ImageDataType::Gray_Gamma16: return new MemoryNonlinearGray16Image(w, h, m); - case GrayA_Gamma8: + case ImageDataType::GrayA_Gamma8: return new MemoryNonlinearGrayA8Image(w, h, m); - case GrayA_Gamma16: + case ImageDataType::GrayA_Gamma16: return new MemoryNonlinearGrayA16Image(w, h, m); default: throw POV_EXCEPTION_STRING("Image::Create Exception TODO"); // TODO FIXME WIP @@ -3863,47 +3851,47 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, const vect { switch(t) { - case Bit_Map: + case ImageDataType::Bit_Map: return new MemoryBitMapImage(w, h, m); - case Colour_Map: + case ImageDataType::Colour_Map: return new MemoryColourMapImage(w, h, m); - case Gray_Int8: + case ImageDataType::Gray_Int8: return new MemoryGray8Image(w, h, m); - case Gray_Int16: + case ImageDataType::Gray_Int16: return new MemoryGray16Image(w, h, m); - case GrayA_Int8: + case ImageDataType::GrayA_Int8: return new MemoryGrayA8Image(w, h, m); - case GrayA_Int16: + case ImageDataType::GrayA_Int16: return new MemoryGrayA16Image(w, h, m); - case RGB_Int8: + case ImageDataType::RGB_Int8: return new MemoryRGB8Image(w, h, m); - case RGB_Int16: + case ImageDataType::RGB_Int16: return new MemoryRGB16Image(w, h, m); - case RGBA_Int8: + case ImageDataType::RGBA_Int8: return new MemoryRGBA8Image (w, h, m); - case RGBA_Int16: + case ImageDataType::RGBA_Int16: return new MemoryRGBA16Image(w, h, m); - case RGBFT_Float: + case ImageDataType::RGBFT_Float: #ifdef FILE_MAPPED_IMAGE_ALLOCATOR if (allowFileBacking) - return new RGBFTImage >(w, h, m); + return new RGBFTImage>(w, h, m); #endif return new MemoryRGBFTImage(w, h, m); - case RGB_Gamma8: + case ImageDataType::RGB_Gamma8: return new MemoryNonlinearRGB8Image(w, h, m); - case RGB_Gamma16: + case ImageDataType::RGB_Gamma16: return new MemoryNonlinearRGB16Image(w, h, m); - case RGBA_Gamma8: + case ImageDataType::RGBA_Gamma8: return new MemoryNonlinearRGBA8Image (w, h, m); - case RGBA_Gamma16: + case ImageDataType::RGBA_Gamma16: return new MemoryNonlinearRGBA16Image(w, h, m); - case Gray_Gamma8: + case ImageDataType::Gray_Gamma8: return new MemoryNonlinearGray8Image(w, h, m); - case Gray_Gamma16: + case ImageDataType::Gray_Gamma16: return new MemoryNonlinearGray16Image(w, h, m); - case GrayA_Gamma8: + case ImageDataType::GrayA_Gamma8: return new MemoryNonlinearGrayA8Image(w, h, m); - case GrayA_Gamma16: + case ImageDataType::GrayA_Gamma16: return new MemoryNonlinearGrayA16Image(w, h, m); default: throw POV_EXCEPTION_STRING("Image::Create Exception TODO"); // TODO FIXME WIP @@ -3915,7 +3903,7 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, const vect } } -Image *Image::Read(ImageFileType type, IStream *file, const ReadOptions& options) +Image *Image::Read(ImageFileType type, IStream *file, const ImageReadOptions& options) { #ifdef POV_SYS_IMAGE_TYPE if (type == SYS) @@ -4010,7 +3998,7 @@ following built-in formats: GIF, TGA, IFF, PGM, PPM, BMP."); } } -void Image::Write(ImageFileType type, OStream *file, const Image *image, const WriteOptions& options) +void Image::Write(ImageFileType type, OStream *file, const Image *image, const ImageWriteOptions& options) { if (image->GetWidth() == 0 || image->GetHeight() == 0) throw POV_EXCEPTION(kParamErr, "Invalid image size for output"); @@ -4425,3 +4413,4 @@ void Image::SetColourMap(const vector& m) } } +// end of namespace pov_base diff --git a/source/base/image/image.h b/source/base/image/image.h index 68b3d7cae..cee4f1be1 100644 --- a/source/base/image/image.h +++ b/source/base/image/image.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,19 +38,26 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/image/image_fwd.h" -// POV-Ray base header files -#include "base/fileinputoutput.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include +#include + +// POV-Ray header files (base module) +#include "base/colour.h" +#include "base/fileinputoutput_fwd.h" #include "base/pov_err.h" -#include "base/image/colourspace.h" -#include "base/image/encoding.h" +#include "base/image/colourspace_fwd.h" +#include "base/image/dither_fwd.h" namespace pov_base { -class DitherStrategy; -using DitherStrategySPtr = shared_ptr; - //############################################################################## /// /// @defgroup PovBaseImage Image Handling @@ -58,6 +65,147 @@ using DitherStrategySPtr = shared_ptr; /// /// @{ +enum class ImageDataType : int +{ + Undefined, ///< Special value indicating that image decoder is free to pick most fitting type. + Bit_Map, ///< Palette-based image with 2 palette entries. + Colour_Map, ///< Palette-based image with up to 256 palette entries. + Gray_Int8, ///< Single-channel (grayscale) image using 8-bit linear encoding. + Gray_Int16, ///< Single-channel (grayscale) image using 16-bit linear encoding. + GrayA_Int8, ///< Dual-channel (grayscale and alpha) image using 8-bit linear encoding. + GrayA_Int16, ///< Dual-channel (grayscale and alpha) image using 16-bit linear encoding. + RGB_Int8, ///< 3-channel (colour) image using 8-bit linear encoding. + RGB_Int16, ///< 3-channel (colour) image using 16-bit linear encoding. + RGBA_Int8, ///< 4-channel (colour and alpha) image using 8-bit linear encoding. + RGBA_Int16, ///< 4-channel (colour and alpha) image using 16-bit linear encoding. + RGBFT_Float, ///< 5-channel (colour, filter and transmit) image using single-precision floating-point encoding. + RGB_Gamma8, ///< 3-channel (colour) image using 8-bit gamma encoding. + RGB_Gamma16, ///< 3-channel (colour) image using 16-bit gamma encoding. + RGBA_Gamma8, ///< 4-channel (colour and alpha) image using 8-bit gamma colour encoding and 8-bit linear alpha encoding. + RGBA_Gamma16, ///< 4-channel (colour and alpha) image using 16-bit gamma colour encoding and 16-bit linear alpha encoding. + Gray_Gamma8, ///< Single-channel (grayscale) image using 8-bit gamma encoding. + Gray_Gamma16, ///< Single-channel (grayscale) image using 16-bit gamma encoding. + GrayA_Gamma8, ///< Dual-channel (grayscale and alpha) image using 8-bit gamma greyscale encoding and 8-bit linear alpha encoding. + GrayA_Gamma16, ///< Dual-channel (grayscale and alpha) image using 16-bit gamma greyscale encoding and 16-bit linear alpha encoding. +}; + +/// The mode to use for alpha handling. +enum class ImageAlphaMode : int +{ + None, ///< Disable alpha channel. @note Not a valid setting for input files. + Default, ///< Use auto-detection or file format specific default. + Premultiplied, ///< Enforce premultiplied mode, aka associated alpha. + Straight, ///< Enforce straight mode, aka unassociated alpha. +}; + +struct ImageReadOptions final +{ + ImageDataType itype; + SimpleGammaCurvePtr defaultGamma; // the gamma curve to use by default for converting to linear colour space + SimpleGammaCurvePtr workingGamma; // the working colour space gamma + bool gammaOverride; // whether to apply defaultGamma even if the file indicates a different gamma + bool gammacorrect; // whether to do any gamma correction at all; if false, raw encoded values are used + bool premultipliedOverride; // whether to override file-format default for alpha premultiplication + bool premultiplied; // whether to expect premultiplied ("associated") alpha or not ("straight alpha") + mutable std::vector warnings; + + ImageReadOptions() : + itype(ImageDataType::Undefined), + gammaOverride(false), gammacorrect(false), premultipliedOverride(false), premultiplied(false) + {} +}; + +struct ImageWriteOptions final +{ + //------------------------------------------------------------------------------ + /// @name Gamma Handling + /// @{ + + /// Gamma to encode for. + /// Set this to `nullptr` to use the file format specific default. + /// @note + /// This setting is ignored with file formats that mandate linear encoding or a + /// specific encoding gamma. + SimpleGammaCurvePtr encodingGamma; + + /// Working colour space gamma to encode from. + /// Set to `nullptr` or a neutral gamma curve to indicate linear working colour space. + SimpleGammaCurvePtr workingGamma; + + /// @} + //------------------------------------------------------------------------------ + + /// Dithering algorithm. + /// Leave this at the default to disable dithering. + /// @note + /// This setting is ignored with file formats that are not prone to colour banding + /// artifacts (such as OpenEXR) or do not benefit from dithering (such as JPEG). + DitherStrategySPtr ditherStrategy; + + unsigned int offset_x; ///< Currently not actively set. + unsigned int offset_y; ///< Currently not actively set. + + /// How to handle image transparency. + /// Set this to @ref ImageAlphaMode::None to disable creation of an alpha channel, + /// @ref ImageAlphaMode::Default to write an alpha channel using a file format specific + /// default mode, @ref ImageAlphaMode::Premultiplied to write an alpha channel using + /// premultiplied mode (aka associated alpha), or @ref ImageAlphaMode::Straight to write an + /// alpha channel using straight mode (aka unassociated alpha). + /// @note + /// This setting is ignored with file formats that do not support transparency, or + /// for which transparency support has not been implemented in POV-Ray. + ImageAlphaMode alphaMode; + + /// Bits per colour channel. + /// Set this to `0` to use the file format specific default. + /// @note + /// This setting is ignored with file formats that mandate a particular bit depth, + /// for which POV-Ray only supports a particular bit depth, or for which bit depth + /// is not applicable (such as JPEG). + /// @note + /// The actual bit depth may differ if the file format or POV-Ray's implementation + /// thereof does not support the requested bit depth. In that case, the next higher + /// supported bit depth is used if possible, or the highest supported bit depth + /// otherwise. + unsigned char bitsPerChannel; + + /// Whether to use compression. + /// Set this to a negative value to use the file format specific default setting, `0` + /// to disable, or any higher value to enable. Depending on the file format, such a + /// setting may be interpreted as a format specific compression parameter. + /// @note + /// Whether a positive value indicates a mode, compression level or quality level + /// is specific to the file format. + /// @note + /// This setting is ignored with file formats that never use compression, always + /// use compression, or for which POV-Ray's implementation leaves no choice. + signed short compression; + + /// Whether to write a greyscale image. + /// @note + /// This setting is ignored with file formats that do not support a dedicated + /// greyscale mode, or for which support of such a mode has not been implemented + /// in POV-Ray. + bool grayscale : 1; + + ImageWriteOptions(); + + inline bool AlphaIsEnabled() const + { + return (alphaMode != ImageAlphaMode::None); + } + + inline bool AlphaIsPremultiplied(bool defaultToPremultiplied) const + { + if (defaultToPremultiplied) + return (alphaMode != ImageAlphaMode::Straight); + else + return (alphaMode == ImageAlphaMode::Premultiplied); + } + + GammaCurvePtr GetTranscodingGammaCurve(GammaCurvePtr defaultEncodingGamma) const; +}; + /** * Generic image data container. * @@ -75,7 +223,7 @@ using DitherStrategySPtr = shared_ptr; class Image { public: - struct RGBMapEntry + struct RGBMapEntry final { float red; float green; @@ -85,7 +233,7 @@ class Image RGBMapEntry(float r, float g, float b) : red(r), green(g), blue(b) { } }; - struct RGBAMapEntry + struct RGBAMapEntry final { float red; float green; @@ -96,7 +244,7 @@ class Image RGBAMapEntry(float r, float g, float b, float a) : red(r), green(g), blue(b), alpha(a) { } }; - struct RGBFTMapEntry + struct RGBFTMapEntry final { float red; float green; @@ -116,66 +264,6 @@ class Image RGBFTColourMap }; - enum ImageChannelDataType - { - kImageChannelDataType_Int8, - kImageChannelDataType_Int16, - kImageChannelDataType_Gamma8, - kImageChannelDataType_Gamma16, - }; - - enum ImageChannelLayout - { - kImageChannelLayout_Gray, - kImageChannelLayout_GrayA, - kImageChannelLayout_RGB, - kImageChannelLayout_RGBA, - }; - - enum ImageDataType - { - /// Value used to indicate that image decoder is free to pick the most fitting type. - Undefined, - /// Palette-based image with 2 palette entries. - Bit_Map, - /// Palette-based image with up to 256 palette entries. - Colour_Map, - /// Single-channel (grayscale) image using 8-bit linear encoding. - Gray_Int8, - /// Single-channel (grayscale) image using 16-bit linear encoding. - Gray_Int16, - /// Dual-channel (grayscale and alpha) image using 8-bit linear encoding. - GrayA_Int8, - /// Dual-channel (grayscale and alpha) image using 16-bit linear encoding. - GrayA_Int16, - /// 3-channel (colour) image using 8-bit linear encoding. - RGB_Int8, - /// 3-channel (colour) image using 16-bit linear encoding. - RGB_Int16, - /// 4-channel (colour and alpha) image using 8-bit linear encoding. - RGBA_Int8, - /// 4-channel (colour and alpha) image using 16-bit linear encoding. - RGBA_Int16, - /// 5-channel (colour, filter and transmit) image using single-precision floating-point encoding. - RGBFT_Float, - /// 3-channel (colour) image using 8-bit gamma encoding. - RGB_Gamma8, - /// 3-channel (colour) image using 16-bit gamma encoding. - RGB_Gamma16, - /// 4-channel (colour and alpha) image using 8-bit gamma colour encoding and 8-bit linear alpha encoding. - RGBA_Gamma8, - /// 4-channel (colour and alpha) image using 16-bit gamma colour encoding and 16-bit linear alpha encoding. - RGBA_Gamma16, - /// Single-channel (grayscale) image using 8-bit gamma encoding. - Gray_Gamma8, - /// Single-channel (grayscale) image using 16-bit gamma encoding. - Gray_Gamma16, - /// Dual-channel (grayscale and alpha) image using 8-bit gamma greyscale encoding and 8-bit linear alpha encoding. - GrayA_Gamma8, - /// Dual-channel (grayscale and alpha) image using 16-bit gamma greyscale encoding and 16-bit linear alpha encoding. - GrayA_Gamma16 - }; - /// Image file type identifier. enum ImageFileType { @@ -194,140 +282,49 @@ class Image HDR }; - /// The mode to use for alpha handling. - enum AlphaMode - { - kAlphaMode_None, ///< Disable alpha channel. @note Not a valid setting for input files. - kAlphaMode_Default, ///< Use auto-detection or file format specific default. - kAlphaMode_Premultiplied, ///< Enforce premultiplied mode, aka associated alpha. - kAlphaMode_Straight, ///< Enforce straight mode, aka unassociated alpha. - }; - - struct ReadOptions - { - ImageDataType itype; - SimpleGammaCurvePtr defaultGamma; // the gamma curve to use by default for converting to linear colour space - SimpleGammaCurvePtr workingGamma; // the working colour space gamma - bool gammaOverride; // whether to apply defaultGamma even if the file indicates a different gamma - bool gammacorrect; // whether to do any gamma correction at all; if false, raw encoded values are used - bool premultipliedOverride; // whether to override file-format default for alpha premultiplication - bool premultiplied; // whether to expect premultiplied ("associated") alpha or not ("straight alpha") - mutable vector warnings; - - ReadOptions() : itype(Undefined), gammaOverride(false), gammacorrect(false), premultipliedOverride(false), premultiplied(false) { } - }; - - struct WriteOptions - { - //------------------------------------------------------------------------------ - /// @name Gamma Handling - /// @{ - - /// Gamma to encode for. - /// Set this to `nullptr` to use the file format specific default. - /// @note - /// This setting is ignored with file formats that mandate linear encoding or a - /// specific encoding gamma. - SimpleGammaCurvePtr encodingGamma; - - /// Working colour space gamma to encode from. - /// Set to `nullptr` or a neutral gamma curve to indicate linear working colour space. - SimpleGammaCurvePtr workingGamma; - - /// @} - //------------------------------------------------------------------------------ - - /// Dithering algorithm. - /// Leave this at the default to disable dithering. - /// @note - /// This setting is ignored with file formats that are not prone to colour banding - /// artifacts (such as OpenEXR) or do not benefit from dithering (such as JPEG). - DitherStrategySPtr ditherStrategy; - - unsigned int offset_x; ///< Currently not actively set. - unsigned int offset_y; ///< Currently not actively set. - - /// How to handle image transparency. - /// Set this to @ref kAlphaMode_None to disable creation of an alpha channel, - /// @ref kAlphaMode_Default to write an alpha channel using a file format specific - /// default mode, @ref kAlphaMode_Premultiplied to write an alpha channel using - /// premultiplied mode (aka associated alpha), or @ref kAlphaMode_Straight to write an - /// alpha channel using straight mode (aka unassociated alpha). - /// @note - /// This setting is ignored with file formats that do not support transparency, or - /// for which transparency support has not been implemented in POV-Ray. - AlphaMode alphaMode; - - /// Bits per colour channel. - /// Set this to `0` to use the file format specific default. - /// @note - /// This setting is ignored with file formats that mandate a particular bit depth, - /// for which POV-Ray only supports a particular bit depth, or for which bit depth - /// is not applicable (such as JPEG). - /// @note - /// The actual bit depth may differ if the file format or POV-Ray's implementation - /// thereof does not support the requested bit depth. In that case, the next higher - /// supported bit depth is used if possible, or the highest supported bit depth - /// otherwise. - unsigned char bitsPerChannel; - - /// Whether to use compression. - /// Set this to a negative value to use the file format specific default setting, `0` - /// to disable, or any higher value to enable. Depending on the file format, such a - /// setting may be interpreted as a format specific compression parameter. - /// @note - /// Whether a positive value indicates a mode, compression level or quality level - /// is specific to the file format. - /// @note - /// This setting is ignored with file formats that never use compression, always - /// use compression, or for which POV-Ray's implementation leaves no choice. - signed short compression; - - /// Whether to write a greyscale image. - /// @note - /// This setting is ignored with file formats that do not support a dedicated - /// greyscale mode, or for which support of such a mode has not been implemented - /// in POV-Ray. - bool grayscale : 1; - - WriteOptions(); - - inline bool AlphaIsEnabled() const - { - return (alphaMode != Image::kAlphaMode_None); - } - - inline bool AlphaIsPremultiplied(bool defaultToPremultiplied) const - { - if (defaultToPremultiplied) - return (alphaMode != Image::kAlphaMode_Straight); - else - return (alphaMode == Image::kAlphaMode_Premultiplied); - } - - GammaCurvePtr GetTranscodingGammaCurve(GammaCurvePtr defaultEncodingGamma) const - { - if (encodingGamma) - return TranscodingGammaCurve::Get(workingGamma, encodingGamma); - else - return TranscodingGammaCurve::Get(workingGamma, defaultEncodingGamma); - } - }; - virtual ~Image() { } - static ImageDataType GetImageDataType (ImageChannelDataType channelType, ImageChannelLayout layout); + /// Suggest an image data container satisfying certain constraints. + /// + /// This method returns an @ref ImageDataType representing a non-paletted, integer-based + /// image data container matching the specified constraints. + /// + /// @note + /// The number of bits per colour channel is taken as a minimum requirement. All other + /// constraints are currently implemented as exact-match requirements. + /// @note + /// RGB alpha is not supported yet. + /// + /// @param minBitsPerChannel Minimum number of bits per colour or alpha channel. + /// @param colourChannels Number of colour channels (1 = greyscale, 3 = RGB). + /// @param alphaChannels Number of alpha channels (0 = no alpha, 1 = common alpha, 3 = RGB alpha). + /// @param linear Whether the caller will write linear (as opposed to gamma encoded) data. + static ImageDataType GetImageDataType(int minBitsPerChannel, int colourChannels, int alphaChannels, bool linear); + + /// Suggest an image data container satisfying certain constraints. + /// + /// This method is a convenience function equivalent to calling: + /// + /// GetImageDataType(minBitsPerChannel, colourChannels, alpha? 1:0, IsNeutral(gamma)); + /// + /// See @ref GetImageDataType(int,int,int,bool) for more details. + /// + /// @param minBitsPerChannel Minimum number of bits per colour or alpha channel. + /// @param colourChannels Number of colour channels (1 = greyscale, 3 = RGB). + /// @param alpha Whether to provide a (common) alpha channel. + /// @param gamma Encoding gamma of the data to be written. + static ImageDataType GetImageDataType(int minBitsPerChannel, int colourChannels, bool alpha, GammaCurvePtr gamma); static Image *Create(unsigned int w, unsigned int h, ImageDataType t, unsigned int maxRAMmbHint, unsigned int pixelsPerBlockHint); static Image *Create(unsigned int w, unsigned int h, ImageDataType t, bool allowFileBacking = false); - static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const vector& m, bool allowFileBacking = false); - static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const vector& m, bool allowFileBacking = false); - static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const vector& m, bool allowFileBacking = false); + static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m, bool allowFileBacking = false); + static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m, bool allowFileBacking = false); + static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m, bool allowFileBacking = false); // ftype = use this image type, if "Undefined" use best match - static Image *Read(ImageFileType ftype, IStream *file, const ReadOptions& options = ReadOptions()); + static Image *Read(ImageFileType ftype, IStream *file, const ImageReadOptions& options = ImageReadOptions()); - static void Write(ImageFileType ftype, OStream *file, const Image *image, const WriteOptions& options = WriteOptions()); + static void Write(ImageFileType ftype, OStream *file, const Image *image, const ImageWriteOptions& options = ImageWriteOptions()); unsigned int GetWidth() const { return width; } unsigned int GetHeight() const { return height; } @@ -432,13 +429,13 @@ class Image unsigned int GetColourMapSize() const; - void GetColourMap(vector& m) const; - void GetColourMap(vector& m) const; - void GetColourMap(vector& m) const; + void GetColourMap(std::vector& m) const; + void GetColourMap(std::vector& m) const; + void GetColourMap(std::vector& m) const; - void SetColourMap(const vector& m); - void SetColourMap(const vector& m); - void SetColourMap(const vector& m); + void SetColourMap(const std::vector& m); + void SetColourMap(const std::vector& m); + void SetColourMap(const std::vector& m); /* void CopyTo(unsigned int x, unsigned int y, const Image& srcimage) { @@ -449,7 +446,7 @@ class Image // TODO }*/ protected: - struct MapEntry + struct MapEntry final { float red; float green; @@ -464,7 +461,7 @@ class Image MapEntry(const RGBFTMapEntry& e) : red(e.red), green(e.green), blue(e.blue), filter(e.filter), transm(e.transm) { } }; - vector colormap; + std::vector colormap; ColourMapType colormaptype; unsigned int width; unsigned int height; @@ -474,26 +471,24 @@ class Image Image(unsigned int w, unsigned int h, ImageDataType t) : width(w), height(h), type(t), colormaptype(NoColourMap), premultiplied(false) { } - Image(unsigned int w, unsigned int h, ImageDataType t, const vector& m) : - width(w), height(h), type(t), colormaptype(RGBColourMap), premultiplied(false) { colormap.resize(max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } + Image(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m) : + width(w), height(h), type(t), colormaptype(RGBColourMap), premultiplied(false) { colormap.resize(std::max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } - Image(unsigned int w, unsigned int h, ImageDataType t, const vector& m) : - width(w), height(h), type(t), colormaptype(RGBAColourMap), premultiplied(false) { colormap.resize(max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } + Image(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m) : + width(w), height(h), type(t), colormaptype(RGBAColourMap), premultiplied(false) { colormap.resize(std::max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } - Image(unsigned int w, unsigned int h, ImageDataType t, const vector& m) : - width(w), height(h), type(t), colormaptype(RGBFTColourMap), premultiplied(false) { colormap.resize(max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } + Image(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m) : + width(w), height(h), type(t), colormaptype(RGBFTColourMap), premultiplied(false) { colormap.resize(std::max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } float RGB2Gray(float red, float green, float blue) const { return RGBColour(red, green, blue).Greyscale(); } private: - /// not available - Image(); - /// not available - Image(const Image&); - /// not available - Image& operator=(Image&); + + Image() = delete; + Image(const Image&) = delete; + Image& operator=(Image&) = delete; }; /// @} @@ -501,5 +496,6 @@ class Image //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_IMAGE_H diff --git a/source/base/image/image_fwd.h b/source/base/image/image_fwd.h new file mode 100644 index 000000000..5e3980d45 --- /dev/null +++ b/source/base/image/image_fwd.h @@ -0,0 +1,53 @@ +//****************************************************************************** +/// +/// @file base/image/image_fwd.h +/// +/// Forward declarations related to image containers. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_IMAGE_FWD_H +#define POVRAY_BASE_IMAGE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class Image; +struct ImageReadOptions; +struct ImageWriteOptions; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_IMAGE_FWD_H diff --git a/source/base/image/jpeg.cpp b/source/base/image/jpeg.cpp index aa5041f13..22f343372 100644 --- a/source/base/image/jpeg.cpp +++ b/source/base/image/jpeg.cpp @@ -14,7 +14,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -44,15 +44,13 @@ #ifndef LIBJPEG_MISSING -// C++ variants of standard C header files +// C++ variants of C standard header files #include -// Standard C++ header files +// C++ standard header files +#include #include -// Boost header files -#include - // Other 3rd party header files extern "C" { @@ -60,7 +58,11 @@ extern "C" } // POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/image/colourspace.h" #include "base/image/dither.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -83,7 +85,7 @@ const int POV_JPEG_BUFFER_SIZE = 1024; ******************************************************************************/ // write buffer for JPEG images -class POV_JPEG_Write_Buffer +class POV_JPEG_Write_Buffer final { public: POV_JPEG_Write_Buffer(); @@ -96,7 +98,7 @@ class POV_JPEG_Write_Buffer JSAMPROW row_pointer[1]; int row_stride; struct jpeg_compress_struct cinfo; - string msg; + std::string msg; OStream *file; } ; @@ -111,7 +113,7 @@ POV_JPEG_Write_Buffer::POV_JPEG_Write_Buffer() row_stride = 0; } -class POV_JPEG_Read_Buffer +class POV_JPEG_Read_Buffer final { public: POV_JPEG_Read_Buffer(); @@ -124,7 +126,7 @@ class POV_JPEG_Read_Buffer JSAMPROW row_pointer[1]; int row_stride; struct jpeg_decompress_struct cinfo; - string msg; + std::string msg; IStream *file; }; @@ -276,7 +278,7 @@ extern "C" } // TODO: handle possible memory leakage if an exception is thrown during a read -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { int width; int height; @@ -345,16 +347,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options) height = readbuf.cinfo.output_height; width = readbuf.cinfo.output_width; - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - { - if (GammaCurve::IsNeutral(gamma)) - // No gamma correction required, raw values can be stored "as is". - imagetype = readbuf.cinfo.output_components == 1 ? Image::Gray_Int8 : Image::RGB_Int8; - else - // Gamma correction required; use an image container that will take care of that. - imagetype = readbuf.cinfo.output_components == 1 ? Image::Gray_Gamma8 : Image::RGB_Gamma8; - } + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(8, (readbuf.cinfo.output_components == 1 ? 1 : 3), false, gamma); image = Image::Create (width, height, imagetype) ; // NB: JPEG files don't use alpha, so premultiplied vs. non-premultiplied is not an issue image->TryDeferDecoding(gamma, MAXJSAMPLE); // try to have gamma adjustment being deferred until image evaluation. @@ -363,7 +358,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) readbuf.row_stride = readbuf.cinfo.output_width * readbuf.cinfo.output_components; // Make a one-row-high sample array - boost::scoped_array scopedarray (new JSAMPLE [readbuf.row_stride]); + std::unique_ptr scopedarray (new JSAMPLE [readbuf.row_stride]); readbuf.row_pointer[0] = (JSAMPROW) &scopedarray[0] ; // read image row by row @@ -401,7 +396,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) } // TODO: handle possible memory leakage if an exception is thrown during a write -void Write (OStream *file, const Image *image, const Image::WriteOptions& options) +void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { int width = image->GetWidth() ; int height = image->GetHeight() ; @@ -457,7 +452,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option writebuf.row_stride = writebuf.cinfo.image_width * writebuf.cinfo.input_components; // Make a one-row-high sample array - boost::scoped_array scopedarray (new JSAMPLE [writebuf.row_stride]); + std::unique_ptr scopedarray (new JSAMPLE [writebuf.row_stride]); writebuf.row_pointer[0] = (JSAMPROW) &scopedarray[0] ; // if quality is not specified, we wind the output quality waaaay up (usually needed for raytracing) @@ -487,7 +482,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option // prepare metadata Metadata meta; /* Line feed is "local" */ - string comment=string("Render Date: ") + meta.getDateTime() + "\n"; + std::string comment = std::string("Render Date: ") + meta.getDateTime() + "\n"; comment += "Software: " + meta.getSoftware() + "\n"; if (!meta.getComment1().empty()) comment += meta.getComment1() + "\n"; @@ -530,8 +525,10 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option jpeg_destroy_compress(&writebuf.cinfo); } -} // end of namespace Jpeg +} +// end of namespace Jpeg -} // end of namespace pov_base +} +// end of namespace pov_base #endif // LIBJPEG_MISSING diff --git a/source/base/image/jpeg_pov.h b/source/base/image/jpeg_pov.h index 345b659d8..b297c9aef 100644 --- a/source/base/image/jpeg_pov.h +++ b/source/base/image/jpeg_pov.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,15 +60,17 @@ namespace Jpeg /// /// @{ -Image *Read(IStream *file, const Image::ReadOptions& options); -void Write (OStream *file, const Image *image, const Image::WriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); +void Write (OStream *file, const Image *image, const ImageWriteOptions& options); /// @} /// //############################################################################## } +// end of namespace Jpeg } +// end of namespace pov_base #endif // POVRAY_BASE_JPEG_H diff --git a/source/base/image/metadata.cpp b/source/base/image/metadata.cpp index e00cde4df..dbef9a309 100644 --- a/source/base/image/metadata.cpp +++ b/source/base/image/metadata.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,9 +36,13 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/metadata.h" +// C++ variants of C standard header files #include -// POV-Ray base header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/version_info.h" // this must be the last file included @@ -55,60 +59,60 @@ Metadata::Metadata() Metadata::~Metadata() {} -string Metadata::getSoftware() const +std::string Metadata::getSoftware() const { return "POV-Ray v" POV_RAY_SOURCE_VERSION; } -string Metadata::getComment1() const +std::string Metadata::getComment1() const { #ifdef METADATA_PLATFORM_STRING // METADATA_PLATFORM_STRING should be in a form similar to 'i686-pc-linux-gnu', 'i386-pc-win', etc. - return string("Platform: ") + METADATA_PLATFORM_STRING; + return std::string("Platform: ") + METADATA_PLATFORM_STRING; #else - return string(); + return std::string(); #endif } -string Metadata::getComment2() const +std::string Metadata::getComment2() const { #ifdef METADATA_COMPILER_STRING // METADATA_COMPILER_STRING should be in a form similar to 'g++ 4.4.3', 'msvc 10.0', etc. - return string("Compiler: ") + METADATA_COMPILER_STRING; + return std::string("Compiler: ") + METADATA_COMPILER_STRING; #else - return string(); + return std::string(); #endif } -string Metadata::getComment3() const +std::string Metadata::getComment3() const { #ifdef METADATA_COMMENT_3 // NB it is legal for METADATA_COMMENT_3 to be a function returning string // Note that it may be called more than once - return string(METADATA_COMMENT_3); + return std::string(METADATA_COMMENT_3); #else - return string(); + return std::string(); #endif } -string Metadata::getComment4() const +std::string Metadata::getComment4() const { #ifdef METADATA_COMMENT_4 // NB it is legal for METADATA_COMMENT_4 to be a function returning string // Note that it may be called more than once - return string(METADATA_COMMENT_4); + return std::string(METADATA_COMMENT_4); #else - return string(); + return std::string(); #endif } -string Metadata::getDateTime() const +std::string Metadata::getDateTime() const { // Not using boost's `to_iso_extended_string` because that would mean we couldn't reliably // get away with using the boost date_time library in header-only mode. char s[21]; // 10 (date) + 1 (blank) + 8 (time) + 1 (timezone "Z") + 1 (trailing NUL) std::snprintf(s, sizeof(s), "%04d-%02d-%02d %02d:%02d:%02dZ", getYear(), getMonth(), getDay(), getHour(), getMin(), getSec()); - return string(s); + return std::string(s); } int Metadata::getYear() const @@ -142,3 +146,4 @@ int Metadata::getSec() const } } +// end of namespace pov_base diff --git a/source/base/image/metadata.h b/source/base/image/metadata.h index 63a7bd02c..6520c8fed 100644 --- a/source/base/image/metadata.h +++ b/source/base/image/metadata.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,13 +39,19 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include // Boost header files #include #include +// POV-Ray header files (base module) +// (none at the moment) + namespace pov_base { @@ -56,7 +62,7 @@ namespace pov_base /// @{ /// Generates metadata to write into output images. -class Metadata +class Metadata final { public: Metadata(); @@ -67,7 +73,7 @@ class Metadata * @note This method should return at most 40 ascii bytes, otherwise it may become truncated by some file formats. * non-printable characters, line feeds and tabs are not allowed. */ - string getSoftware() const; + std::string getSoftware() const; /* Up to 4 comments, each at most 80 ascii bytes, no line feed, no tab * if it's longer, it can either fit anyway or get truncated, it's the @@ -79,31 +85,31 @@ class Metadata * @note This method should return at most 80 ascii bytes, otherwise it may become truncated by some file formats. * non-printable characters, line feeds and tabs are not allowed. */ - string getComment1() const; + std::string getComment1() const; /** * Get comment string #2. * @note This method should return at most 80 ascii bytes, otherwise it may become truncated by some file formats. * non-printable characters, line feeds and tabs are not allowed. */ - string getComment2() const; + std::string getComment2() const; /** * Get comment string #3. * @note This method should return at most 80 ascii bytes, otherwise it may become truncated by some file formats. * non-printable characters, line feeds and tabs are not allowed. */ - string getComment3() const; + std::string getComment3() const; /** * Get comment string #4. * @note This method should return at most 80 ascii bytes, otherwise it may become truncated by some file formats. * non-printable characters, line feeds and tabs are not allowed. */ - string getComment4() const; + std::string getComment4() const; /// Get date string in ISO 8601 format. - string getDateTime() const; + std::string getDateTime() const; /// Get year (including full century) int getYear() const; @@ -128,4 +134,6 @@ class Metadata //############################################################################## } -#endif +// end of namespace pov_base + +#endif // POVRAY_BASE_METADATA_H diff --git a/source/base/image/openexr.cpp b/source/base/image/openexr.cpp index bdc8bd951..653e6f0d8 100644 --- a/source/base/image/openexr.cpp +++ b/source/base/image/openexr.cpp @@ -38,12 +38,12 @@ #ifndef OPENEXR_MISSING -// Standard C++ header files -#include +// C++ variants of C standard header files +// (none at the moment) -// Boost header files -#include -#include +// C++ standard header files +#include +#include // Other 3rd party header files #include @@ -51,9 +51,13 @@ #include #include -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/stringutilities.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -75,28 +79,23 @@ using namespace Imath; /***************************************************************************** * Local typedefs ******************************************************************************/ -struct Messages -{ - vector warnings; - string error; -}; /////////////////////////////////////////// // class POV_EXR_OStream /////////////////////////////////////////// -class POV_EXR_OStream : public Imf::OStream +class POV_EXR_OStream final : public Imf::OStream { public: POV_EXR_OStream(pov_base::OStream& pov_stream) : Imf::OStream(UCS2toSysString(pov_stream.Name()).c_str()), os(pov_stream) { } - virtual ~POV_EXR_OStream() { } + virtual ~POV_EXR_OStream() override { } - void write(const char *c, int n) + virtual void write(const char *c, int n) override { if(os.write(c, n) == false) throw POV_EXCEPTION(kFileDataErr, "Error while writing EXR output"); } - Int64 tellp() + virtual Int64 tellp() override { unsigned long pos = os.tellg(); if((int) pos == -1) @@ -104,7 +103,7 @@ class POV_EXR_OStream : public Imf::OStream return(pos); } - void seekp(Int64 pos) + virtual void seekp(Int64 pos) override { if(os.seekg((unsigned long)pos) == false) throw POV_EXCEPTION(kFileDataErr, "Error when writing EXR output"); @@ -116,7 +115,7 @@ class POV_EXR_OStream : public Imf::OStream /////////////////////////////////////////// // class POV_EXR_IStream /////////////////////////////////////////// -class POV_EXR_IStream : public Imf::IStream +class POV_EXR_IStream final : public Imf::IStream { public: POV_EXR_IStream(pov_base::IStream& pov_stream) : Imf::IStream(UCS2toSysString(pov_stream.Name()).c_str()), is(pov_stream) @@ -126,18 +125,18 @@ class POV_EXR_IStream : public Imf::IStream is.seekg(0, IOBase::seek_set); } - virtual ~POV_EXR_IStream() { } + virtual ~POV_EXR_IStream() override { } - void clear(void) { is.clearstate(); } + virtual void clear(void) override { is.clearstate(); } - bool read(char *c, int n) + virtual bool read(char *c, int n) override { if(is.read(c, n) == false) throw POV_EXCEPTION(kFileDataErr, "Error while reading EXR file"); return (is.tellg() < fsize); } - Int64 tellg() + virtual Int64 tellg() override { unsigned long pos = is.tellg(); if((int)pos == -1) @@ -145,7 +144,7 @@ class POV_EXR_IStream : public Imf::IStream return pos; } - void seekg(Int64 pos) + virtual void seekg(Int64 pos) override { if(is.seekg((unsigned long)pos) == false) throw POV_EXCEPTION(kFileDataErr, "Error while reading EXR file"); @@ -159,7 +158,7 @@ class POV_EXR_IStream : public Imf::IStream * Implementation ******************************************************************************/ -Image *Read(IStream *file, const Image::ReadOptions& options) +Image *Read(IStream *file, const ImageReadOptions& options) { unsigned int width; unsigned int height; @@ -189,7 +188,7 @@ Image *Read(IStream *file, const Image::ReadOptions& options) RgbaInputFile rif(is); Array2D pixels; Box2i dw = rif.dataWindow(); - Image::ImageDataType imagetype = options.itype; + ImageDataType imagetype = options.itype; width = dw.max.x - dw.min.x + 1; height = dw.max.y - dw.min.y + 1; @@ -197,8 +196,8 @@ Image *Read(IStream *file, const Image::ReadOptions& options) rif.setFrameBuffer(&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width); rif.readPixels(dw.min.y, dw.max.y); - if(imagetype == Image::Undefined) - imagetype = Image::RGBFT_Float; + if(imagetype == ImageDataType::Undefined) + imagetype = ImageDataType::RGBFT_Float; image = Image::Create(width, height, imagetype); image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication @@ -220,14 +219,14 @@ Image *Read(IStream *file, const Image::ReadOptions& options) return image; } -void Write(OStream *file, const Image *image, const Image::WriteOptions& options) +void Write(OStream *file, const Image *image, const ImageWriteOptions& options) { int width = image->GetWidth(); int height = image->GetHeight(); bool use_alpha = image->HasTransparency() && options.AlphaIsEnabled(); float pixelAspect = 1.0; Header hdr(width, height, pixelAspect, Imath::V2f(0, 0), 1.0, INCREASING_Y, ZIP_COMPRESSION); - boost::scoped_array pixels(new Rgba[width * height]); + std::unique_ptr pixels(new Rgba[width * height]); Rgba *p = pixels.get(); // OpenEXR format mandates that colours are encoded linearly. @@ -263,7 +262,7 @@ void Write(OStream *file, const Image *image, const Image::WriteOptions& options channels = WRITE_RGB; // write RGB Metadata meta; - string comments; + std::string comments; if (!meta.getComment1().empty()) comments += meta.getComment1() + "\n"; if (!meta.getComment2().empty()) @@ -276,8 +275,8 @@ void Write(OStream *file, const Image *image, const Image::WriteOptions& options if (!comments.empty()) hdr.insert("comments",StringAttribute(comments)); - string software= meta.getSoftware(); - string datetime= meta.getDateTime(); + std::string software= meta.getSoftware(); + std::string datetime= meta.getDateTime(); hdr.insert("software",StringAttribute(software)); hdr.insert("creation",StringAttribute(datetime)); @@ -291,8 +290,10 @@ void Write(OStream *file, const Image *image, const Image::WriteOptions& options } } -} // end of namespace OpenEXR +} +// end of namespace OpenEXR -} // end of namespace pov_base +} +// end of namespace pov_base #endif // OPENEXR_MISSING diff --git a/source/base/image/openexr.h b/source/base/image/openexr.h index 04540c1c5..8e19ba5b4 100644 --- a/source/base/image/openexr.h +++ b/source/base/image/openexr.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,15 +60,17 @@ namespace OpenEXR /// /// @{ -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace OpenEXR } +// end of namespace pov_base #endif // POVRAY_BASE_OPENEXR_H diff --git a/source/base/image/png.cpp b/source/base/image/png.cpp index 1151bbbae..83c0d3804 100644 --- a/source/base/image/png.cpp +++ b/source/base/image/png.cpp @@ -13,7 +13,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -43,16 +43,23 @@ #ifndef LIBPNG_MISSING -// C++ standard headers +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include +#include -// other 3rd party library headers +// other 3rd party library header files #include -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -82,10 +89,10 @@ const int MAXTEXT = 1024; // Maximum length of a tEXt message /***************************************************************************** * Local typedefs ******************************************************************************/ -struct Messages +struct Messages final { - vector warnings; - string error; + std::vector warnings; + std::string error; }; /***************************************************************************** @@ -134,7 +141,7 @@ extern "C" Messages *m = reinterpret_cast(png_get_error_ptr(png_ptr)); if (m) - m->warnings.push_back (string(msg)) ; + m->warnings.push_back (std::string(msg)) ; } @@ -164,7 +171,7 @@ extern "C" Messages *m = reinterpret_cast(png_get_error_ptr(png_ptr)); if (m) - m->error = string(msg) ; + m->error = std::string(msg) ; throw POV_EXCEPTION(kFileDataErr, msg); } @@ -312,7 +319,7 @@ extern "C" ******************************************************************************/ // TODO: use scoped clean-up class in case of exception -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { int stride; int j; @@ -386,7 +393,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) if (color_type == PNG_COLOR_TYPE_PALETTE) { // color palette image - vector colormap ; + std::vector colormap; Image::RGBAMapEntry entry; png_colorp palette; int cmap_len; @@ -408,9 +415,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options) colormap.push_back (entry); } - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = Image::Colour_Map; + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = ImageDataType::Colour_Map; image = Image::Create (width, height, imagetype, colormap) ; image->SetPremultiplied(premul); // specify whether the color map data has premultiplied alpha gamma.reset(); // gamma has been taken care of by transforming the color table. @@ -422,7 +429,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) { // grayscale image // (To keep the actual data reading code simple, we're pretending this to be a color palette image.) - vector colormap ; + std::vector colormap; Image::RGBAMapEntry entry; int cmap_len = 1 << bit_depth; bool has_alpha = png_get_valid(r_png_ptr, r_info_ptr, PNG_INFO_tRNS); @@ -440,9 +447,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options) colormap.push_back (entry); } - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = has_alpha ? Image::GrayA_Int8 : Image::Gray_Int8; + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = has_alpha ? ImageDataType::GrayA_Int8 : ImageDataType::Gray_Int8; image = Image::Create (width, height, imagetype, colormap) ; image->SetPremultiplied(premul); // specify whether the color map data has premultiplied alpha gamma.reset(); // gamma has been taken care of by transforming the color table. @@ -512,25 +519,10 @@ Image *Read (IStream *file, const Image::ReadOptions& options) // grayscale image // (note that although 8-bit greyscale images should have been handled earlier already, 8-bit greyscale + 8-bit alpha images haven't.) - Image::ImageDataType imagetype = options.itype; + ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - { - if (GammaCurve::IsNeutral(gamma)) - { - if (has_alpha) - imagetype = bit_depth > 8 ? Image::GrayA_Int16 : Image::GrayA_Int8; - else - imagetype = bit_depth > 8 ? Image::Gray_Int16 : Image::Gray_Int8; - } - else - { - if (has_alpha) - imagetype = bit_depth > 8 ? Image::GrayA_Gamma16 : Image::GrayA_Gamma8; - else - imagetype = bit_depth > 8 ? Image::Gray_Gamma16 : Image::Gray_Gamma8; - } - } + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(bit_depth, 1, has_alpha, gamma); image = Image::Create (width, height, imagetype); image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication @@ -581,25 +573,10 @@ Image *Read (IStream *file, const Image::ReadOptions& options) else { // color image ((color_type & PNG_COLOR_MASK_COLOR) != 0) - Image::ImageDataType imagetype = options.itype; + ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - { - if (GammaCurve::IsNeutral(gamma)) - { - if (has_alpha) - imagetype = bit_depth > 8 ? Image::RGBA_Int16 : Image::RGBA_Int8; - else - imagetype = bit_depth > 8 ? Image::RGB_Int16 : Image::RGB_Int8; - } - else - { - if (has_alpha) - imagetype = bit_depth > 8 ? Image::RGBA_Gamma16 : Image::RGBA_Gamma8; - else - imagetype = bit_depth > 8 ? Image::RGB_Gamma16 : Image::RGB_Gamma8; - } - } + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(bit_depth, 3, has_alpha, gamma); image = Image::Create (width, height, imagetype); image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication @@ -672,7 +649,7 @@ void SetChannelValue(png_bytep& p, unsigned int v, unsigned int bpcc) *(p++) = (v & 0xFF); } -void Write (OStream *file, const Image *image, const Image::WriteOptions& options) +void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { int png_stride; int width = image->GetWidth() ; @@ -775,7 +752,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option #if defined(PNG_WRITE_TEXT_SUPPORTED) /* Line feed is "local" */ - string comment=string("Render Date: ") + meta.getDateTime() + "\n"; + std::string comment = std::string("Render Date: ") + meta.getDateTime() + "\n"; if (!meta.getComment1().empty()) comment += meta.getComment1() + "\n"; if (!meta.getComment2().empty()) @@ -784,7 +761,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option comment += meta.getComment3() + "\n"; if (!meta.getComment4().empty()) comment += meta.getComment4() + "\n"; - string soft (meta.getSoftware()); + std::string soft (meta.getSoftware()); png_text p_text[2] = { { PNG_TEXT_COMPRESSION_NONE, const_cast("Software"), const_cast(soft.c_str()), soft.length() }, { PNG_TEXT_COMPRESSION_NONE, const_cast("Comment"), const_cast(comment.c_str()), comment.length() }, @@ -855,8 +832,10 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option png_destroy_write_struct(&png_ptr, &info_ptr); } -} // end of namespace Png +} +// end of namespace Png -} // end of namespace pov_base +} +// end of namespace pov_base #endif // LIBPNG_MISSING diff --git a/source/base/image/png_pov.h b/source/base/image/png_pov.h index 6def3c23f..d21fbafc6 100644 --- a/source/base/image/png_pov.h +++ b/source/base/image/png_pov.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -54,15 +59,17 @@ namespace Png /// /// @{ -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace Png } +// end of namespace pov_base #endif // POVRAY_BASE_PNG_H diff --git a/source/base/image/ppm.cpp b/source/base/image/ppm.cpp index 6a16efa98..664971752 100644 --- a/source/base/image/ppm.cpp +++ b/source/base/image/ppm.cpp @@ -20,7 +20,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -48,14 +48,18 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/ppm.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include -// Standard C++ header files -#include +// C++ standard header files +// (none at the moment) -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -76,7 +80,7 @@ enum NetpbmDataFormat /*****************************************************************************/ -void Write (OStream *file, const Image *image, const Image::WriteOptions& options) +void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { int file_type = POV_File_Image_PPM; int width = image->GetWidth() ; @@ -287,7 +291,7 @@ inline static POV_UINT16 ReadNetpbmRasterValue (IStream *file, NetpbmDataFormat /*****************************************************************************/ // TODO: make sure we destroy the image if we throw an exception -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { POV_UINT32 width; POV_UINT32 height; @@ -358,14 +362,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options) // We'll be using an image container that provides for automatic decoding if possible - unless there's no such decoding to do. gamma = ScaledGammaCurve::GetByDecoding(float(maxImageVal)/float(maxval), gamma); // Note that we'll apply the scaling even if we don't officially gamma-correct - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = Image::GetImageDataType( GammaCurve::IsNeutral(gamma) ? (is16BitData ? Image::kImageChannelDataType_Int16 - : Image::kImageChannelDataType_Int8) - : (is16BitData ? Image::kImageChannelDataType_Gamma16 - : Image::kImageChannelDataType_Gamma8), - isMonochrome ? Image::kImageChannelLayout_Gray - : Image::kImageChannelLayout_RGB ); + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType((is16BitData ? 16 : 8), (isMonochrome ? 1 : 3), false, gamma); image = Image::Create (width, height, imagetype) ; // NB: PGM files don't use alpha, so premultiplied vs. non-premultiplied is not an issue image->TryDeferDecoding(gamma, maxImageVal); // try to have gamma adjustment being deferred until image evaluation. @@ -394,7 +393,8 @@ Image *Read (IStream *file, const Image::ReadOptions& options) return image; } -} // end of namespace Netpbm - -} // end of namespace pov_base +} +// end of namespace Netpbm +} +// end of namespace pov_base diff --git a/source/base/image/ppm.h b/source/base/image/ppm.h index e6f01e02c..8e04a7607 100644 --- a/source/base/image/ppm.h +++ b/source/base/image/ppm.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,15 +60,17 @@ namespace Netpbm /// /// @{ -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace Netpbm } +// end of namespace pov_base #endif // POVRAY_BASE_PPM_H diff --git a/source/base/image/targa.cpp b/source/base/image/targa.cpp index ed9e39d2b..85b489e6f 100644 --- a/source/base/image/targa.cpp +++ b/source/base/image/targa.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -56,11 +56,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/targa.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -72,13 +80,16 @@ namespace pov_base namespace Targa { -typedef struct pix +using std::vector; + +struct pix final { unsigned int b; unsigned int g; unsigned int r; unsigned int a; -} Pixel; +}; +using Pixel = pix; typedef char Targa_footer[26]; #define FOO_EXT_OFF 0 @@ -120,7 +131,7 @@ static void PutPix (vector& line, const pix *pixel, bool opaque) line.push_back (pixel->a); } -void Write (OStream *file, const Image *image, const Image::WriteOptions& options) +void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { pix current; pix next; @@ -295,10 +306,10 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option // let's prepare the Extension area, then write Extension then footer ext[EXT_SIZE_OFF+1] = (unsigned char) ((495 >> 8) & 0xff); ext[EXT_SIZE_OFF] = (unsigned char) (495 & 0xff); - string soft = meta.getSoftware().substr(0,EXT_SOFT_DIM-1); + std::string soft = meta.getSoftware().substr(0,EXT_SOFT_DIM-1); sprintf(&ext[EXT_SOFT_OFF],"%s",soft.c_str()); - string com = meta.getComment1().substr(0,EXT_COMMENT_DIM-1); + std::string com = meta.getComment1().substr(0,EXT_COMMENT_DIM-1); if (!com.empty()) sprintf(&ext[EXT_COMMENT_OFF],"%s",com.c_str()); com = meta.getComment2().substr(0,EXT_COMMENT_DIM-1); @@ -470,7 +481,7 @@ static void ConvertColor (Image::RGBAMapEntry *pixel, unsigned pixelsize, const * ******************************************************************************/ -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { int temp; int h; @@ -560,25 +571,18 @@ Image *Read (IStream *file, const Image::ReadOptions& options) ConvertColor (&entry, cmsiz, bytes, gamma); colormap.push_back(entry); } - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = Image::Colour_Map ; + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = ImageDataType::Colour_Map ; image = Image::Create (width, height, imagetype, colormap) ; image->SetPremultiplied(premul); // specify whether the color map data has premultiplied alpha gamma.reset(); // gamma has been taken care of by transforming the color table. } else { - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - { - if (GammaCurve::IsNeutral(gamma)) - // No gamma correction required, raw values can be stored "as is". - imagetype = opaque ? Image::RGB_Int8 : Image::RGBA_Int8 ; - else - // Gamma correction required; use an image container that will take care of that. - imagetype = opaque ? Image::RGB_Gamma8 : Image::RGBA_Gamma8 ; - } + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(8, 3, !opaque, gamma); image = Image::Create (width, height, imagetype) ; image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication image->TryDeferDecoding(gamma, 255); // try to have gamma adjustment being deferred until image evaluation. @@ -706,7 +710,8 @@ Image *Read (IStream *file, const Image::ReadOptions& options) return (image); } -} // end of namespace Targa - } +// end of namespace Targa +} +// end of namespace pov_base diff --git a/source/base/image/targa.h b/source/base/image/targa.h index 3b499f393..8d6c33871 100644 --- a/source/base/image/targa.h +++ b/source/base/image/targa.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -54,15 +59,17 @@ namespace Targa /// /// @{ -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace Targa } +// end of namespace pov_base #endif // POVRAY_BASE_TARGA_H diff --git a/source/base/image/tiff.cpp b/source/base/image/tiff.cpp index 00ba245d6..5f6b26e61 100644 --- a/source/base/image/tiff.cpp +++ b/source/base/image/tiff.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,7 +38,11 @@ #ifndef LIBTIFF_MISSING -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include // Boost header files @@ -56,6 +60,13 @@ extern "C" #include } +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/povassert.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" + // this must be the last file included other than tiffio.h #include "base/povdebug.h" @@ -157,7 +168,7 @@ static void Tiff_Unmap(thandle_t, tdata_t, toff_t) * ******************************************************************************/ -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { int nrow; int result = 0; @@ -259,7 +270,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) TIFFGetField(tif, TIFFTAG_COLORMAP, &red, &green, &blue); - vector colormap ; + std::vector colormap; Image::RGBMapEntry entry; // I may be mistaken, but it appears that alpha/opacity information doesn't @@ -288,13 +299,13 @@ Image *Read (IStream *file, const Image::ReadOptions& options) } } - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = Image::Colour_Map; + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = ImageDataType::Colour_Map; image = Image::Create (width, height, imagetype, colormap) ; image->SetPremultiplied(premul); // specify whether the color map data has premultiplied alpha - boost::scoped_array buf (new unsigned char [TIFFStripSize(tif)]); + std::unique_ptr buf (new unsigned char [TIFFStripSize(tif)]); //read the tiff lines and save them in the image //with RGB mode, we have to change the order of the 3 samples RGB <=> BGR @@ -310,11 +321,11 @@ Image *Read (IStream *file, const Image::ReadOptions& options) else { // Allocate the row buffers for the image - boost::scoped_array buf (new uint32 [width * height]) ; + std::unique_ptr buf (new uint32 [width * height]) ; - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = ( GammaCurve::IsNeutral(gamma) ? Image::RGBA_Int8 : Image::RGBA_Gamma8 ); + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(8, 3, true, gamma); image = Image::Create (width, height, imagetype) ; image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication image->TryDeferDecoding(gamma, 255); // try to have gamma adjustment being deferred until image evaluation. @@ -340,8 +351,10 @@ Image *Read (IStream *file, const Image::ReadOptions& options) return (image) ; } -} // end of namespace Tiff +} +// end of namespace Tiff } +// end of namespace pov_base #endif // LIBTIFF_MISSING diff --git a/source/base/image/tiff_pov.h b/source/base/image/tiff_pov.h index 51558d962..deba2d0b5 100644 --- a/source/base/image/tiff_pov.h +++ b/source/base/image/tiff_pov.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -54,14 +59,16 @@ namespace Tiff /// /// @{ -Image *Read(IStream *file, const Image::ReadOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace Tiff } +// end of namespace pov_base #endif // POVRAY_BASE_TIFF_H diff --git a/source/base/mathutil.cpp b/source/base/mathutil.cpp index 6c4f6cc79..b865da346 100644 --- a/source/base/mathutil.cpp +++ b/source/base/mathutil.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,12 +36,12 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/mathutil.h" -// C++ variants of standard C header files -#include -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) -// Standard C++ header files -#include +// POV-Ray header files (base module) +// (none at the moment) // this must be the last file included #include "base/povdebug.h" @@ -49,25 +49,7 @@ namespace pov_base { -#ifdef NEED_INVHYP -DBL asinh(DBL x) -{ - return (x < 0 ? -1 : (x > 0 ? 1 : 0)) * log(fabs(x) + sqrt(1 + x * x)); -} - -DBL acosh(DBL x) -{ - if(x < 1.0) - return 0; - return log(x + sqrt(x * x - 1)); -} - -DBL atanh(DBL x) -{ - if(fabs(x) >= 1) - return 0; - return 0.5 * log((1 + x) / (1 - x)); -} -#endif +// nothing in here at the moment } +// end of namespace pov_base diff --git a/source/base/mathutil.h b/source/base/mathutil.h index 55f9a957d..7d1488aaa 100644 --- a/source/base/mathutil.h +++ b/source/base/mathutil.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,9 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -#include +// C++ variants of C standard header files +// (none at the moment) -#include "base/types.h" +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/povassert.h" namespace pov_base { @@ -53,17 +58,11 @@ namespace pov_base /// /// @{ -#ifdef NEED_INVHYP -DBL asinh(DBL x); -DBL acosh(DBL x); -DBL atanh(DBL x); -#endif - // Get minimum/maximum of three values. template -inline T max3(T x, T y, T z) { return max(x, max(y, z)); } +inline T max3(T x, T y, T z) { return std::max(x, std::max(y, z)); } template -inline T min3(T x, T y, T z) { return min(x, min(y, z)); } +inline T min3(T x, T y, T z) { return std::min(x, std::min(y, z)); } template inline T clip(T val, T minv, T maxv); @@ -195,5 +194,6 @@ inline bool IsFinite(double value) //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_MATHUTIL_H diff --git a/source/base/messenger.cpp b/source/base/messenger.cpp index 4ce567256..da16d0979 100644 --- a/source/base/messenger.cpp +++ b/source/base/messenger.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,11 +36,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/messenger.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include #include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" // this must be the last file included @@ -421,3 +425,4 @@ void GenericMessenger::CleanupString(char *str) } } +// end of namespace pov_base diff --git a/source/base/messenger.h b/source/base/messenger.h index bbffe445b..d1c07c9af 100644 --- a/source/base/messenger.h +++ b/source/base/messenger.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,9 +36,19 @@ #ifndef POVRAY_BASE_MESSENGER_H #define POVRAY_BASE_MESSENGER_H +// Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/messenger_fwd.h" -#include "base/types.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/base_fwd.h" +#include "base/stringtypes.h" namespace pov_base { @@ -49,8 +59,6 @@ namespace pov_base /// /// @{ -class Exception; - /// @relates GenericMessenger enum MessageClass { @@ -140,5 +148,6 @@ class GenericMessenger //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_MESSENGER_H diff --git a/source/base/messenger_fwd.h b/source/base/messenger_fwd.h new file mode 100644 index 000000000..e5d997d10 --- /dev/null +++ b/source/base/messenger_fwd.h @@ -0,0 +1,52 @@ +//****************************************************************************** +/// +/// @file base/messenger_fwd.h +/// +/// Forward declarations related to ... what? +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_MESSENGER_FWD_H +#define POVRAY_BASE_MESSENGER_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class MessageContext; +class GenericMessenger; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_MESSENGER_FWD_H diff --git a/source/base/path.cpp b/source/base/path.cpp index bcef1a8c4..08b55bda5 100644 --- a/source/base/path.cpp +++ b/source/base/path.cpp @@ -36,8 +36,13 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/path.h" -// POV-Ray base header files +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/stringutilities.h" // this must be the last file included #include "base/povdebug.h" @@ -45,6 +50,9 @@ namespace pov_base { +using std::string; +using std::vector; + Path::Path() { } @@ -327,3 +335,4 @@ UCS2String Path::URLToUCS2String(const string& p) const } } +// end of namespace pov_base diff --git a/source/base/path.h b/source/base/path.h index 9cd756a3a..a52c06ed2 100644 --- a/source/base/path.h +++ b/source/base/path.h @@ -38,14 +38,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/path_fwd.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include -// POV-Ray base header files -#include "base/stringutilities.h" -#include "base/types.h" +// POV-Ray header files (base module) +#include "base/stringtypes.h" namespace pov_base { @@ -57,7 +60,7 @@ namespace pov_base /// /// @{ -class Path +class Path final { public: @@ -91,16 +94,16 @@ class Path UCS2String GetVolume() const; UCS2String GetFolder() const; - vector GetAllFolders() const; + std::vector GetAllFolders() const; UCS2String GetFile() const; void SetVolume(const char *p); - void SetVolume(const string& p); + void SetVolume(const std::string& p); void SetVolume(const UCS2 *p); void SetVolume(const UCS2String& p); void AppendFolder(const char *p); - void AppendFolder(const string& p); + void AppendFolder(const std::string& p); void AppendFolder(const UCS2 *p); void AppendFolder(const UCS2String& p); @@ -108,7 +111,7 @@ class Path void RemoveAllFolders(); void SetFile(const char *p); - void SetFile(const string& p); + void SetFile(const std::string& p); void SetFile(const UCS2 *p); void SetFile(const UCS2String& p); @@ -119,7 +122,7 @@ class Path private: UCS2String volume; - vector folders; + std::vector folders; UCS2String file; /// Analyze a path string. @@ -129,7 +132,7 @@ class Path /// if the string does not match the platform-specific conventions. /// /// @note - /// This method calls @ref ParsePathString(UCS2String&,vector,UCS2String&,const UCS2String&) + /// This method calls @ref ParsePathString(UCS2String&,std::vector,UCS2String&,const UCS2String&) /// to do the actual work. /// void ParsePathString(const UCS2String& p); @@ -162,10 +165,10 @@ class Path /// @return Whether the string constitutes a valid path and/or file name according to the /// platform-specific conventions. /// - static bool ParsePathString (UCS2String& v, vector& d, UCS2String& f, const UCS2String& p); + static bool ParsePathString (UCS2String& v, std::vector& d, UCS2String& f, const UCS2String& p); UCS2String URLToUCS2String(const char *p) const; - UCS2String URLToUCS2String(const string& p) const; + UCS2String URLToUCS2String(const std::string& p) const; }; /// @} @@ -173,5 +176,6 @@ class Path //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_PATH_H diff --git a/source/base/path_fwd.h b/source/base/path_fwd.h new file mode 100644 index 000000000..aec3bb35a --- /dev/null +++ b/source/base/path_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file base/path_fwd.h +/// +/// Forward declarations related to file paths. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_PATH_FWD_H +#define POVRAY_BASE_PATH_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class Path; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_PATH_FWD_H diff --git a/source/base/platformbase.cpp b/source/base/platformbase.cpp index f46953384..97560d44f 100644 --- a/source/base/platformbase.cpp +++ b/source/base/platformbase.cpp @@ -36,8 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/platformbase.h" -// POV-Ray base header files -#include "base/types.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/filesystem.h" +#include "base/povassert.h" +#include "base/stringutilities.h" // this must be the last file included #include "base/povdebug.h" @@ -47,6 +53,23 @@ namespace pov_base //****************************************************************************** +PlatformBase::PlatformBase() +{ + POV_ASSERT(self == nullptr); + self = this; +}; + +PlatformBase::~PlatformBase() +{ + self = nullptr; +}; + +PlatformBase& PlatformBase::GetInstance() +{ + POV_ASSERT(self != nullptr); + return *self; +}; + /// Platform specific function interface self reference pointer PlatformBase *PlatformBase::self = nullptr; @@ -82,7 +105,7 @@ UCS2String DefaultPlatformBase::CreateTemporaryFile() void DefaultPlatformBase::DeleteTemporaryFile(const UCS2String& filename) { - remove(UCS2toSysString(filename).c_str()); + (void)pov_base::Filesystem::DeleteFile(filename); } bool DefaultPlatformBase::ReadFileFromURL(OStream *, const UCS2String&, const UCS2String&) @@ -95,11 +118,6 @@ FILE* DefaultPlatformBase::OpenLocalFile(const UCS2String& name, const char *mod return fopen(UCS2toSysString(name).c_str(), mode); } -void DefaultPlatformBase::DeleteLocalFile(const UCS2String& name) -{ - POV_DELETE_FILE(UCS2toSysString(name).c_str()); -} - bool DefaultPlatformBase::AllowLocalFileAccess(const UCS2String& name, const unsigned int fileType, bool write) { return true; @@ -108,3 +126,4 @@ bool DefaultPlatformBase::AllowLocalFileAccess(const UCS2String& name, const uns //****************************************************************************** } +// end of namespace pov_base diff --git a/source/base/platformbase.h b/source/base/platformbase.h index 626c2451e..01aabe1cd 100644 --- a/source/base/platformbase.h +++ b/source/base/platformbase.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,13 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// Standard C++ header files -#include +// C++ variants of C standard header files +#include -// POV-Ray base header files -#include "base/fileinputoutput.h" -#include "base/stringutilities.h" -#include "base/types.h" +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/stringtypes.h" namespace pov_base { @@ -58,8 +60,6 @@ namespace pov_base /// /// @{ -#define POV_PLATFORM_BASE PlatformBase::GetPlatformBaseReference() - /// Abstract class defining an interface to platform-specific services. /// /// @note @@ -69,8 +69,8 @@ class PlatformBase { public: - PlatformBase() { POV_ASSERT(!self); self = this; }; - virtual ~PlatformBase() { self = nullptr; }; + PlatformBase(); + virtual ~PlatformBase(); virtual UCS2String GetTemporaryPath() = 0; virtual UCS2String CreateTemporaryFile() = 0; @@ -85,12 +85,6 @@ class PlatformBase /// virtual FILE* OpenLocalFile (const UCS2String& name, const char *mode) = 0; - /// Delete a file. - /// - /// This method removes a file from the local file system. - /// - virtual void DeleteLocalFile (const UCS2String& name) = 0; - /// Check whether a file is allowed to be accessed. /// /// This method shall determine whether a file on the local file system may be accessed for reading, or created @@ -108,7 +102,7 @@ class PlatformBase /// virtual bool AllowLocalFileAccess (const UCS2String& name, const unsigned int fileType, bool write) = 0; - static PlatformBase& GetInstance() { return *self; }; + static PlatformBase& GetInstance(); private: @@ -117,29 +111,25 @@ class PlatformBase /// Default implementation of @ref PlatformBase. /// -class DefaultPlatformBase : public PlatformBase +class DefaultPlatformBase final : public PlatformBase { public: DefaultPlatformBase(); - ~DefaultPlatformBase(); - - virtual UCS2String GetTemporaryPath(); - virtual UCS2String CreateTemporaryFile(); - virtual void DeleteTemporaryFile(const UCS2String& filename); + virtual ~DefaultPlatformBase() override; - virtual bool ReadFileFromURL(OStream *file, const UCS2String& url, const UCS2String& referrer = UCS2String()); + virtual UCS2String GetTemporaryPath() override; + virtual UCS2String CreateTemporaryFile() override; + virtual void DeleteTemporaryFile(const UCS2String& filename) override; - /// @note - /// This implementation only supports ASCII filenames. - virtual FILE* OpenLocalFile(const UCS2String& name, const char *mode); + virtual bool ReadFileFromURL(OStream *file, const UCS2String& url, const UCS2String& referrer = UCS2String()) override; /// @note /// This implementation only supports ASCII filenames. - virtual void DeleteLocalFile(const UCS2String& name); + virtual FILE* OpenLocalFile(const UCS2String& name, const char *mode) override; /// @note /// This implementation grants unrestricted access to any file. - virtual bool AllowLocalFileAccess(const UCS2String& name, const unsigned int fileType, bool write); + virtual bool AllowLocalFileAccess(const UCS2String& name, const unsigned int fileType, bool write) override; }; /// @} @@ -147,5 +137,6 @@ class DefaultPlatformBase : public PlatformBase //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_PLATFORMBASE_H diff --git a/source/base/pov_err.cpp b/source/base/pov_err.cpp index 827b00bf1..0dd27b01f 100644 --- a/source/base/pov_err.cpp +++ b/source/base/pov_err.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,10 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/pov_err.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -183,3 +189,4 @@ std::string Exception::lookup_code(int err, const char *file, unsigned int line) } } +// end of namespace pov_base diff --git a/source/base/pov_err.h b/source/base/pov_err.h index ccfbb0a03..06dd1f5a7 100644 --- a/source/base/pov_err.h +++ b/source/base/pov_err.h @@ -39,10 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +// C++ variants of C standard header files +// (none at the moment) + // C++ standard header files #include #include +// POV-Ray header files (base module) +// (none at the moment) + namespace pov_base { @@ -132,9 +138,10 @@ class Exception : public std::runtime_error * Create a new exception without location information. * @param str Error message string. */ - Exception(const char *str) throw() : - std::runtime_error(str), xfunction(nullptr), xfile(nullptr), xline(0), xcode(0), - xcodevalid(false), xfrontendnotified(false) + Exception(const char *str) noexcept : + std::runtime_error(str), + xfunction(nullptr), xfile(nullptr), xline(0), + xcode(0), xcodevalid(false), xfrontendnotified(false) {} /** @@ -144,7 +151,11 @@ class Exception : public std::runtime_error * @param li `__LINE__` * @param err Error number. */ - Exception(const char *fn, const char *fi, unsigned int li, int err) throw() : std::runtime_error(Exception::lookup_code(err, fi, li)), xfunction(fn), xfile(fi), xline(li), xcode(err), xcodevalid(true), xfrontendnotified(false) { } + Exception(const char *fn, const char *fi, unsigned int li, int err) noexcept : + std::runtime_error(Exception::lookup_code(err, fi, li)), + xfunction(fn), xfile(fi), xline(li), + xcode(err), xcodevalid(true), xfrontendnotified(false) + {} /** * Create a new exception with code, location information, and an explicit message. @@ -153,7 +164,11 @@ class Exception : public std::runtime_error * @param li `__LINE__` * @param str Error message string. */ - Exception(const char *fn, const char *fi, unsigned int li, const char *str) throw() : std::runtime_error(str), xfunction(fn), xfile(fi), xline(li), xcode(0), xcodevalid(false), xfrontendnotified(false) { } + Exception(const char *fn, const char *fi, unsigned int li, const char *str) noexcept : + std::runtime_error(str), + xfunction(fn), xfile(fi), xline(li), + xcode(0), xcodevalid(false), xfrontendnotified(false) + {} /** * Create a new exception with code, location information, and an explicit message. @@ -162,7 +177,11 @@ class Exception : public std::runtime_error * @param li `__LINE__` * @param str Error message string. */ - Exception(const char *fn, const char *fi, unsigned int li, const string& str) throw() : std::runtime_error(str), xfunction(fn), xfile(fi), xline(li), xcode(0), xcodevalid(false), xfrontendnotified(false) { } + Exception(const char *fn, const char *fi, unsigned int li, const std::string& str) noexcept : + std::runtime_error(str), + xfunction(fn), xfile(fi), xline(li), + xcode(0), xcodevalid(false), xfrontendnotified(false) + {} /** * Create a new exception with code, location information, and an explicit message. @@ -172,7 +191,11 @@ class Exception : public std::runtime_error * @param err Error number. * @param str Error message string. */ - Exception(const char *fn, const char *fi, unsigned int li, int err, const char *str) throw() : std::runtime_error(str), xfunction(fn), xfile(fi), xline(li), xcode(err), xcodevalid(true), xfrontendnotified(false) { } + Exception(const char *fn, const char *fi, unsigned int li, int err, const char *str) noexcept : + std::runtime_error(str), + xfunction(fn), xfile(fi), xline(li), + xcode(err), xcodevalid(true), xfrontendnotified(false) + {} /** * Create a new exception with code, location information, and an explicit message. @@ -182,12 +205,16 @@ class Exception : public std::runtime_error * @param err Error number. * @param str Error message string. */ - Exception(const char *fn, const char *fi, unsigned int li, int err, const string& str) throw() : std::runtime_error(str), xfunction(fn), xfile(fi), xline(li), xcode(err), xcodevalid(true), xfrontendnotified(false) { } + Exception(const char *fn, const char *fi, unsigned int li, int err, const std::string& str) noexcept : + std::runtime_error(str), + xfunction(fn), xfile(fi), xline(li), + xcode(err), xcodevalid(true), xfrontendnotified(false) + {} /** * Destructor. */ - virtual ~Exception() throw() { } + virtual ~Exception() noexcept override { } /** * Determine the function name where the exception occurred. @@ -233,10 +260,10 @@ class Exception : public std::runtime_error /** * Set the front-end notification flag - * @param yes true to indicate notification has been passed on + * @param notified true to indicate notification has been passed on * @return previous value of notification flag */ - bool frontendnotified(bool yes) { bool oldval = xfrontendnotified; xfrontendnotified = yes; return oldval; } + bool frontendnotified(bool notified) { bool oldval = xfrontendnotified; xfrontendnotified = notified; return oldval; } /** * Return the error description for the given code. @@ -265,5 +292,6 @@ class Exception : public std::runtime_error //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_POV_ERR_H diff --git a/source/base/pov_mem.cpp b/source/base/pov_mem.cpp index 4c2fee510..838eea34e 100644 --- a/source/base/pov_mem.cpp +++ b/source/base/pov_mem.cpp @@ -16,7 +16,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -44,9 +44,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/pov_mem.h" +// C++ variants of C standard header files #include #include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" // this must be the last file included @@ -55,6 +60,8 @@ namespace pov_base { +using std::size_t; + /************************************************************************ * AUTHOR * @@ -178,7 +185,7 @@ number of calls to malloc/free and some other statistics. #define MEM_HEADER_ALIGNMENT sizeof(double) #endif - struct mem_node + struct mem_node final { #ifdef MEM_TAG int tag; @@ -770,3 +777,4 @@ void *pov_memmove (void *dest, const void *src, size_t length) } } +// end of namespace pov_base diff --git a/source/base/pov_mem.h b/source/base/pov_mem.h index 261e8c973..6b3fa5267 100644 --- a/source/base/pov_mem.h +++ b/source/base/pov_mem.h @@ -13,7 +13,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,8 +41,18 @@ #ifndef POVRAY_BASE_POV_MEM_H #define POVRAY_BASE_POV_MEM_H +// Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +// C++ variants of C standard header files +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + namespace pov_base { @@ -54,16 +64,17 @@ namespace pov_base void mem_init (void); void mem_release_all (void); -void *pov_malloc (size_t size, const char *file, int line, const char *msg); -void *pov_realloc (void *ptr, size_t size, const char *file, int line, const char *msg); +void *pov_malloc (std::size_t size, const char *file, int line, const char *msg); +void *pov_realloc (void *ptr, std::size_t size, const char *file, int line, const char *msg); void pov_free (void *ptr, const char *file, int line); char *pov_strdup (const char *s); -void *pov_memmove (void *dest, const void *src, size_t length); +void *pov_memmove (void *dest, const void *src, std::size_t length); /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_POV_MEM_H diff --git a/source/base/povassert.h b/source/base/povassert.h new file mode 100644 index 000000000..e763888a1 --- /dev/null +++ b/source/base/povassert.h @@ -0,0 +1,119 @@ +//****************************************************************************** +/// +/// @file base/povassert.h +/// +/// Declarations related to run-time sanity checks. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_POVASSERT_H +#define POVRAY_BASE_POVASSERT_H + +// Module config header file must be the first file included within POV-Ray unit header files +#include "base/configbase.h" + +// C++ variants of C standard header files +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/pov_err.h" + +namespace pov_base +{ + +//############################################################################## +/// +/// @addtogroup PovBase +/// +/// @{ + +/// A macro wrapping a sequence of statements into a single one. +/// +/// This macro is intended to be used in the definition of other macros that should behave +/// syntactically like a single statement, while evaluating to something that would not normally +/// behave that way. +/// +/// Example: +/// +/// #declare FOO(x) SINGLE_STATEMENT( char buf[128]; foo(buf,x); ) +/// ... +/// if (some_cond) +/// FOO(a); +/// else +/// ... +/// +#define SINGLE_STATEMENT( block ) do { block } while (false) + +/// A macro that does nothing. +/// +/// This macro is intended to be used in the definition of other macros that should behave +/// syntactically like a single statement, while evaluating to a no-operation. +/// +/// Example: +/// +/// #declare MY_ASSERT(x) NO_OP +/// ... +/// if (some_cond) +/// MY_ASSERT(some_test); +/// else +/// ... +/// +#define NO_OP SINGLE_STATEMENT(;) + +/// A macro that tests an expression and, if it evaluates false, throws an exception to allow the +/// application to fail gracefully. +/// +#define POV_ASSERT_SOFT(expr) SINGLE_STATEMENT( if(!(expr)) throw POV_EXCEPTION_CODE(kUncategorizedError); ) + +/// A macro that tests an expression and, if it evaluates false, causes a hard crash to generate a +/// core dump or break to a debugger. +/// +#define POV_ASSERT_HARD(expr) assert(expr) + +/// A macro that does nothing, but is mapped to standard `assert()` during static code analysis. +/// +#ifdef STATIC_CODE_ANALYSIS + #define POV_ASSERT_DISABLE(expr) assert(expr) +#else + #define POV_ASSERT_DISABLE(expr) NO_OP +#endif + + +/// @} +/// +//############################################################################## + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_POVASSERT_H diff --git a/source/base/precomp.h b/source/base/precomp.h index 0ece245bc..9c8636a86 100644 --- a/source/base/precomp.h +++ b/source/base/precomp.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,10 +45,10 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -// Module config header file must be the first file included within POV-Ray unit header files -#include "base/configbase.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED -// C++ variants of standard C header files +// C++ variants of C standard header files +#include #include #include #include @@ -57,7 +57,7 @@ #include #include -// Standard C++ header files +// C++ standard header files #include #include #include @@ -75,12 +75,8 @@ #include #include #include -#include -#include -#include #if POV_MULTITHREADED #include #include #endif #include - diff --git a/source/base/safemath.h b/source/base/safemath.h index 897749ae6..ca71ff596 100644 --- a/source/base/safemath.h +++ b/source/base/safemath.h @@ -24,7 +24,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -55,11 +55,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/povassert.h" namespace pov_base { @@ -174,5 +178,6 @@ static inline T SafeSignedProduct(T p1, T p2, T p3 = 1, T p4 = 1) //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_SAFEMATH_H diff --git a/source/base/stringtypes.h b/source/base/stringtypes.h new file mode 100644 index 000000000..e628aece4 --- /dev/null +++ b/source/base/stringtypes.h @@ -0,0 +1,163 @@ +//****************************************************************************** +/// +/// @file base/stringtypes.h +/// +/// Declarations related to string types. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_STRINGTYPES_H +#define POVRAY_BASE_STRINGTYPES_H + +// Module config header file must be the first file included within POV-Ray unit header files +#include "base/configbase.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +namespace pov_base +{ + +//############################################################################## +/// +/// @addtogroup PovBase +/// +/// @{ + +//****************************************************************************** + +//****************************************************************************** +/// +/// @name Character Types +/// Character types with encoding semantics. +/// +/// The following types are used throughout POV-Ray instead of the fundamental +/// character types (`char`, `char16_t` and `char32_t`, respectively), +/// to more clearly identify the character encoding associated with them. +/// While they are normally aliased to the fundamental types, static code +/// analysis tools may still treat them as distinct types to ferret out +/// character encoding incompatibilities between different portions of the code. +/// +/// @note +/// There are currently no aliases provided for `wchar_t`. +/// +/// @{ + +/// UTF-16 code unit. +/// This type should be used instead of `char16_t` wherever UTF-16 +/// encoding is guaranteed or required. +/// @note +/// Code handling data of this type must expect and properly handle +/// surrogate pairs. Code that can only handle the BMP subset of UTF-16 +/// should use @ref UCS2Char instead. +/// @note +/// Code that is agnostic about the details of string encoding (including +/// the actual code unit size and whether it is dealing with code points or +/// actual characters) should use @ref POVChar instead. +using UTF16 = char16_t; + +/// Genuine UCS-2 character. +/// This type should be used wherever UCS-2 encoding (aka "BMP-only UTF-16") +/// is required. +/// @deprecated +/// Code that is agnostic about the details of string encoding (including +/// the actual code unit size) should use @ref POVChar instead. Code that +/// requires 16-bit code units but can handle surrogate pairs should use +/// @ref UTF16Unit instead. +using UCS2 = char16_t; + +/// Arbitrary UCS character. +/// This type should be used wherever code needs to operate on proper characters +/// (as opposed to code units), but is not bound to a particular character set +/// (or is bound to using UCS). +using UCS4 = char32_t; + +//****************************************************************************** +/// +/// @name String Types +/// Character string types with encoding semantics. +/// +/// The following types are used throughout POV-Ray instead of the standard C++ +/// string types (`std::string`, `std::u8string`, `std::u16tring` etc.), +/// to more clearly identify the character encoding associated with them. +/// While they are effectively aliased to the standard types, static code +/// analysis tools may still treat them as distinct types to ferret out +/// character encoding incompatibilities between different portions of the code. +/// +/// See @ref base/stringutilities.h for functions to convert between these +/// string types. +/// +/// @note +/// There are currently no aliases provided for `std::wstring`. +/// +/// @{ + +/// Type holding an @glossary{UTF8}-encoded string of characters. +/// +/// @todo +/// Aliasing this as `std::string` may not be ideal, as it creates ambiguity +/// with the use of that same type for ASCII strings. On the other hand, +/// if we use `std::basic_string`, it isn't compatible with +/// the C++11 `u8"..."` UTF-8 string literal notation, which is of type +/// `const char[]`. +/// +using UTF8String = std::string; + +/// Type holding an @glossary{UCS2}-encoded string of characters. +/// +/// @todo +/// UCS-2 is a poor choice for internal string representation, as it cannot +/// encode the full UCS/Unicode character set; we should use either UTF-8 +/// (the best space saver for the strings to be expected), or UTF-32 +/// (allowing easiest processing). We shouldn't use UTF-16, as it needs +/// about just as much special processing as UTF-8 (but people tend to +/// forget that, confusing UTF-16 with UCS-2), and for the expected typical +/// ASCII-heavy use it is less memory-efficient than UTF-8. +/// +using UCS2String = std::basic_string; + +/// @} +/// +//****************************************************************************** + +/// @} +/// +//############################################################################## + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_STRINGTYPES_H diff --git a/source/base/stringutilities.cpp b/source/base/stringutilities.cpp index 5881a3872..003ac0931 100644 --- a/source/base/stringutilities.cpp +++ b/source/base/stringutilities.cpp @@ -36,7 +36,7 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "stringutilities.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include #include @@ -49,6 +49,9 @@ // Boost header files // (none at the moment) +// POV-Ray header files (base module) +#include "base/types.h" + // this must be the last file included #include "base/povdebug.h" @@ -232,8 +235,8 @@ int pov_stricmp(const char *s1, const char *s2) c1 = *s1++; c2 = *s2++; - c1 = (char)toupper(c1); - c2 = (char)toupper(c2); + c1 = (char)std::toupper(c1); + c2 = (char)std::toupper(c2); if(c1 < c2) return -1; @@ -303,6 +306,21 @@ std::size_t UCS2_strlen(const UCS2* str) return (end - str); } +//------------------------------------------------------------------------------ + +int UCS2_strcmp(const UCS2 *s1, const UCS2 *s2) +{ + UCS2 t1, t2; + + while ((t1 = *s1++) == (t2 = *s2++)) + { + if (t1 == '\0') + return 0; + } + + return (t1 - t2); +} + //****************************************************************************** namespace UCS @@ -644,4 +662,5 @@ const Charset* Charset::Get(CharsetID charset) } } -} // end of namespace pov_base +} +// end of namespace pov_base diff --git a/source/base/stringutilities.h b/source/base/stringutilities.h index bbc22a776..d0b20f8c1 100644 --- a/source/base/stringutilities.h +++ b/source/base/stringutilities.h @@ -43,11 +43,15 @@ #include // C++ standard header files +#include + // Boost header files // (none at the moment) // POV-Ray header files (base module) -#include "base/types.h" +#include "base/base_fwd.h" +#include "base/povassert.h" +#include "base/stringtypes.h" namespace pov_base { @@ -71,6 +75,7 @@ int pov_stricmp(const char *, const char *); const char *pov_tsprintf(const char *, ...); std::size_t UCS2_strlen(const UCS2* str); +int UCS2_strcmp(const UCS2* s1, const UCS2* s2); //****************************************************************************** @@ -268,6 +273,7 @@ struct Charset /// //############################################################################## -} // end of namespace pov_base +} +// end of namespace pov_base #endif // POVRAY_BASE_STRINGUTILITIES_H diff --git a/source/base/textstream.cpp b/source/base/textstream.cpp index 0383b7db1..aac2dec6d 100644 --- a/source/base/textstream.cpp +++ b/source/base/textstream.cpp @@ -36,13 +36,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "textstream.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include #include -// Standard C++ header files +// C++ standard header files #include +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/path.h" +#include "base/stringutilities.h" // this must be the last file included #include "base/povdebug.h" @@ -50,6 +56,9 @@ namespace pov_base { +using std::min; +using std::max; + ITextStream::ITextStream() : lineno(1) { @@ -499,3 +508,4 @@ void OTextStream::flush() } } +// end of namespace pov_base diff --git a/source/base/textstream.h b/source/base/textstream.h index 005c3aed1..ac376effd 100644 --- a/source/base/textstream.h +++ b/source/base/textstream.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,27 +33,23 @@ /// //****************************************************************************** -#ifndef TEXTSTREAM_H -#define TEXTSTREAM_H +#ifndef POVRAY_BASE_TEXTSTREAM_H +#define POVRAY_BASE_TEXTSTREAM_H // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/textstream_fwd.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include -// must nuke these since everyone's favourite monopoly's cstdio still defines -// them for some reason (why not just use inlines like everyone else?) -#undef getc -#undef putc -#undef getchar -#undef putchar +// C++ standard header files +// (none at the moment) -// POV-Ray base header files -#include "base/fileinputoutput.h" +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" #include "base/pov_err.h" -#include "base/stringutilities.h" -#include "base/types.h" +#include "base/stringtypes.h" namespace pov_base { @@ -70,7 +66,7 @@ const int ITEXTSTREAM_BUFFER_SIZE = DEFAULT_ITEXTSTREAM_BUFFER_SIZE; class ITextStream { public: - struct FilePos + struct FilePos final { POV_OFF_T offset; POV_LONG lineno; @@ -97,7 +93,7 @@ class ITextStream POV_LONG lineno; }; -class IBufferedTextStream : public ITextStream +class IBufferedTextStream final : public ITextStream { public: IBufferedTextStream(const UCS2 *, unsigned int); @@ -107,19 +103,19 @@ class IBufferedTextStream : public ITextStream /// @param[in] initialLine First line number as known to the user. IBufferedTextStream(const UCS2 *formalName, IStream *byteStream, POV_LONG initialLine = 1); - virtual ~IBufferedTextStream(); + virtual ~IBufferedTextStream() override; - virtual int getchar(); - virtual void ungetchar(int); + virtual int getchar() override; + virtual void ungetchar(int) override; - virtual bool eof() const; - virtual bool seekg(FilePos); - virtual FilePos tellg() const; + virtual bool eof() const override; + virtual bool seekg(FilePos) override; + virtual FilePos tellg() const override; - virtual bool ReadRaw(unsigned char* buf, size_t size); + virtual bool ReadRaw(unsigned char* buf, size_t size) override; /// Formal name of the file, e.g. to be displayed in error messages. - virtual const UCS2 *name() const { return filename.c_str(); }; + virtual const UCS2 *name() const override { return filename.c_str(); }; private: IStream *stream; unsigned char buffer[ITEXTSTREAM_BUFFER_SIZE]; @@ -133,7 +129,7 @@ class IBufferedTextStream : public ITextStream void RefillBuffer(); }; -class IMemTextStream : public ITextStream +class IMemTextStream final : public ITextStream { public: /// @param[in] formalName Name by which the file is known to the user. @@ -142,19 +138,19 @@ class IMemTextStream : public ITextStream /// @param[in] formalStart File position of buffer start as known to the user. IMemTextStream(const UCS2 *formalName, const unsigned char* data, size_t size, const FilePos& formalStart); - virtual ~IMemTextStream(); + virtual ~IMemTextStream() override; - virtual int getchar(); - virtual void ungetchar(int); + virtual int getchar() override; + virtual void ungetchar(int) override; - virtual bool eof() const; - virtual bool seekg(FilePos); - virtual FilePos tellg() const; + virtual bool eof() const override; + virtual bool seekg(FilePos) override; + virtual FilePos tellg() const override; - virtual bool ReadRaw(unsigned char* buf, size_t size); + virtual bool ReadRaw(unsigned char* buf, size_t size) override; /// Formal name of the file, e.g. to be displayed in error messages. - virtual const UCS2 *name() const { return filename.c_str(); }; + virtual const UCS2 *name() const override { return filename.c_str(); }; private: const unsigned char* buffer; size_t bufferoffset; @@ -193,5 +189,6 @@ class OTextStream //############################################################################## } +// end of namespace pov_base -#endif +#endif // POVRAY_BASE_TEXTSTREAM_H diff --git a/source/base/textstream_fwd.h b/source/base/textstream_fwd.h new file mode 100644 index 000000000..cd2f74cbc --- /dev/null +++ b/source/base/textstream_fwd.h @@ -0,0 +1,52 @@ +//****************************************************************************** +/// +/// @file base/textstream_fwd.h +/// +/// Forward declarations related to buffered text file output. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_TEXTSTREAM_FWD_H +#define POVRAY_BASE_TEXTSTREAM_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class ITextStream; +class OTextStream; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_TEXTSTREAM_FWD_H diff --git a/source/base/textstreambuffer.cpp b/source/base/textstreambuffer.cpp index b87b5aa6d..19b211c26 100644 --- a/source/base/textstreambuffer.cpp +++ b/source/base/textstreambuffer.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,15 +36,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/textstreambuffer.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include #include -// Standard C++ header files +// C++ standard header files #include -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/pov_err.h" #include "base/stringutilities.h" #include "base/types.h" @@ -55,6 +55,9 @@ namespace pov_base { +using std::min; +using std::max; + TextStreamBuffer::TextStreamBuffer(size_t buffersize, unsigned int wrapwidth) { boffset = 0; @@ -332,3 +335,4 @@ void TextStreamBuffer::directflush(const char *str, unsigned int chars) } } +// end of namespace pov_base diff --git a/source/base/textstreambuffer.h b/source/base/textstreambuffer.h index cae6ec84d..86f56fd75 100644 --- a/source/base/textstreambuffer.h +++ b/source/base/textstreambuffer.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,23 +33,22 @@ /// //****************************************************************************** -#ifndef TEXTSTREAMBUFFER_H -#define TEXTSTREAMBUFFER_H +#ifndef POVRAY_BASE_TEXTSTREAMBUFFER_H +#define POVRAY_BASE_TEXTSTREAMBUFFER_H // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/textstreambuffer_fwd.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include -#include #include -// must nuke these since everyone's favourite monopoly's cstdio still defines -// them for some reason (why not just use inlines like everyone else?) -#undef getc -#undef putc -#undef getchar -#undef putchar +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) namespace pov_base { @@ -93,5 +92,6 @@ class TextStreamBuffer //############################################################################## } +// end of namespace pov_base -#endif +#endif // POVRAY_BASE_TEXTSTREAMBUFFER_H diff --git a/source/base/textstreambuffer_fwd.h b/source/base/textstreambuffer_fwd.h new file mode 100644 index 000000000..9a223fff9 --- /dev/null +++ b/source/base/textstreambuffer_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file base/textstreambuffer_fwd.h +/// +/// Forward declarations related to buffered text file output. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_TEXTSTREAMBUFFER_FWD_H +#define POVRAY_BASE_TEXTSTREAMBUFFER_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class TextStreamBuffer; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_TEXTSTREAMBUFFER_FWD_H diff --git a/source/base/timer.cpp b/source/base/timer.cpp index 24aeabbbe..2ffe0270b 100644 --- a/source/base/timer.cpp +++ b/source/base/timer.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,12 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/timer.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + // Boost header files #if POV_MULTITHREADED #include #endif -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/types.h" // this must be the last file included @@ -92,3 +96,4 @@ void Timer::Reset() #endif // POV_USE_DEFAULT_TIMER } +// end of namespace pov_base diff --git a/source/base/timer.h b/source/base/timer.h index c02f1744a..6c0204349 100644 --- a/source/base/timer.h +++ b/source/base/timer.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,11 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// Boost header files #if POV_USE_DEFAULT_TIMER #include #endif @@ -47,6 +52,9 @@ #include "syspovtimer.h" #endif +// POV-Ray header files (base module) +// (none at the moment) + namespace pov_base { @@ -105,7 +113,7 @@ void Delay(unsigned int msec); /// Windows), and/or may be limited to timespans in the order of an hour (any system with a /// 32-bit `clock_t` and a standard `CLOCKS_PER_SEC` of 1,000,000). /// -class Timer +class Timer final { public: @@ -193,5 +201,6 @@ class Timer //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_TIMER_H diff --git a/source/base/types.h b/source/base/types.h index a382068d5..43e7b22ca 100644 --- a/source/base/types.h +++ b/source/base/types.h @@ -36,13 +36,18 @@ #ifndef POVRAY_BASE_TYPES_H #define POVRAY_BASE_TYPES_H +// Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/base_fwd.h" -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include -#include +// POV-Ray header files (base module) +#include "base/pov_err.h" #include "base/pov_mem.h" namespace pov_base @@ -54,23 +59,6 @@ namespace pov_base /// /// @{ -/// A macro wrapping a sequence of statements into a single one. -/// -/// This macro is intended to be used in the definition of other macros that should behave -/// syntactically like a single statement, while evaluating to something that would not normally -/// behave that way. -/// -/// Example: -/// -/// #declare FOO(x) SINGLE_STATEMENT( char buf[128]; foo(buf,x); ) -/// ... -/// if (some_cond) -/// FOO(a); -/// else -/// ... -/// -#define SINGLE_STATEMENT( block ) do { block } while (false) - //****************************************************************************** /// /// @name Theoretical Integer Limits @@ -209,44 +197,6 @@ namespace pov_base /// //****************************************************************************** -/// A macro that does nothing. -/// -/// This macro is intended to be used in the definition of other macros that should behave -/// syntactically like a single statement, while evaluating to a no-operation. -/// -/// Example: -/// -/// #declare MY_ASSERT(x) NO_OP -/// ... -/// if (some_cond) -/// MY_ASSERT(some_test); -/// else -/// ... -/// -#define NO_OP SINGLE_STATEMENT(;) - -/// A macro that tests an expression and, if it evaluates false, throws an exception to allow the -/// application to fail gracefully. -/// -#define POV_ASSERT_SOFT(expr) SINGLE_STATEMENT( if(!(expr)) throw POV_EXCEPTION_CODE(kUncategorizedError); ) - -/// A macro that tests an expression and, if it evaluates false, causes a hard crash to generate a -/// core dump or break to a debugger. -/// -#define POV_ASSERT_HARD(expr) assert(expr) - -/// A macro that does nothing, but is mapped to standard `assert()` during static code analysis. -/// -#ifdef STATIC_CODE_ANALYSIS - #define POV_ASSERT_DISABLE(expr) assert(expr) -#else - #define POV_ASSERT_DISABLE(expr) NO_OP -#endif - -// from ; we don't want to always type the namespace for these. -using std::min; -using std::max; - // from ; we don't want to always type the namespace for these. using std::abs; using std::acos; @@ -272,11 +222,7 @@ using std::sqrt; using std::tan; using std::tanh; -/// 5-dimensional vector type shared between parser and splines. -/// @todo Make this obsolete. -typedef DBL EXPRESS[5]; - -struct POVRect +struct POVRect final { unsigned int top; unsigned int left; @@ -293,7 +239,7 @@ struct POVRect }; /// Legacy (v3.5) `charset` setting. -enum LegacyCharset +enum LegacyCharset : int { kUnspecified, ///< Global settings `charset` not specified. kASCII, ///< Global settings `charset ascii` specified. @@ -317,7 +263,7 @@ enum LegacyCharset /// code page numbers. If you add more character sets, please stick to this scheme wherever /// applicable, or use negative values. /// -enum class CharsetID +enum class CharsetID : int { kUndefined = 0, ///< Special value representing undefined character set. @@ -332,30 +278,6 @@ enum class CharsetID ///< remapping U+0000-U+00FF to U+F000-U+F0FF. }; -/// Type holding an @glossary{UTF8}-encoded string of characters. -/// -/// @todo -/// Aliasing this as `std::string` may not be ideal, as it creates ambiguity -/// with the use of that same type for ASCII strings. On the other hand, -/// if we use `std::basic_string`, it isn't compatible with -/// the C++11 `u8"..."` UTF-8 string literal notation, which is of type -/// `const char[]`. -/// -using UTF8String = std::string; - -/// Type holding an @glossary{UCS2}-encoded string of characters. -/// -/// @todo -/// UCS-2 is a poor choice for internal string representation, as it cannot -/// encode the full UCS/Unicode character set; we should use either UTF-8 -/// (the best space saver for the strings to be expected), or UTF-32 -/// (allowing easiest processing). We shouldn't use UTF-16, as it needs -/// about just as much special processing as UTF-8 (but people tend to -/// forget that, confusing UTF-16 with UCS-2), and for the expected typical -/// ASCII-heavy use it is less memory-efficient than UTF-8. -/// -using UCS2String = std::basic_string; - enum GammaMode { /** @@ -410,5 +332,6 @@ class ThreadData //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_TYPES_H diff --git a/source/core/bounding/bounding.cpp b/source/core/bounding/bounding.cpp index b20602849..f9c5eb90c 100644 --- a/source/core/bounding/bounding.cpp +++ b/source/core/bounding/bounding.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/bounding/bounding.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -45,3 +53,4 @@ namespace pov // nothing in here yet } +// end of namespace pov diff --git a/source/core/bounding/bounding.h b/source/core/bounding/bounding.h index db8187360..e5ee39c6c 100644 --- a/source/core/bounding/bounding.h +++ b/source/core/bounding/bounding.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + namespace pov { @@ -56,5 +64,6 @@ namespace pov //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BOUNDING_H diff --git a/source/core/bounding/boundingbox.cpp b/source/core/bounding/boundingbox.cpp index bbd94ce78..d02901029 100644 --- a/source/core/bounding/boundingbox.cpp +++ b/source/core/bounding/boundingbox.cpp @@ -12,7 +12,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,8 +40,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/bounding/boundingbox.h" +// C++ variants of C standard header files +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/object.h" @@ -53,6 +61,8 @@ namespace pov { +using std::vector; + const int BUNCHING_FACTOR = 4; // Initial number of entries in a priority queue. const int INITIAL_PRIORITY_QUEUE_SIZE = 256; @@ -842,13 +852,13 @@ bool sort_and_split(BBOX_TREE **Root, BBOX_TREE **&Finite, size_t *numOfFiniteOb switch(Axis) { case X: - QSORT(reinterpret_cast(&Finite[first]), size, sizeof(BBOX_TREE *), compboxes); + std::qsort(Finite + first, size, sizeof(BBOX_TREE*), compboxes); break; case Y: - QSORT(reinterpret_cast(&Finite[first]), size, sizeof(BBOX_TREE *), compboxes); + std::qsort(Finite + first, size, sizeof(BBOX_TREE*), compboxes); break; case Z: - QSORT(reinterpret_cast(&Finite[first]), size, sizeof(BBOX_TREE *), compboxes); + std::qsort(Finite + first, size, sizeof(BBOX_TREE*), compboxes); break; } @@ -915,3 +925,4 @@ bool sort_and_split(BBOX_TREE **Root, BBOX_TREE **&Finite, size_t *numOfFiniteOb } } +// end of namespace pov diff --git a/source/core/bounding/boundingbox.h b/source/core/bounding/boundingbox.h index 434a15171..928a13e71 100644 --- a/source/core/bounding/boundingbox.h +++ b/source/core/bounding/boundingbox.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,9 +38,21 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/bounding/boundingbox_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/matrix.h" +#include "core/render/ray_fwd.h" namespace pov { @@ -52,11 +64,8 @@ namespace pov /// /// @{ -class Intersection; -class Ray; struct RayObjectCondition; class RenderStatistics; -class TraceThreadData; /***************************************************************************** * Global preprocessor defines @@ -82,7 +91,7 @@ typedef GenericVector3d BBoxVector3d; /// bounding data in min/max format rather than lowerLeft/size, and making sure /// high-precision values are rounded towards positive/negative infinity as appropriate. /// -struct BoundingBox +struct BoundingBox final { BBoxVector3d lowerLeft; BBoxVector3d size; @@ -154,19 +163,15 @@ inline bool Inside_BBox(const Vector3d& point, const BoundingBox& bbox) /// Structure holding bounding box data in min/max format. /// -struct MinMaxBoundingBox +struct MinMaxBoundingBox final { BBoxVector3d pmin; BBoxVector3d pmax; }; -typedef struct BBox_Tree_Struct BBOX_TREE; -typedef BBOX_TREE* BBoxTreePtr; -typedef const BBOX_TREE* ConstBBoxTreePtr; - -struct BBox_Tree_Struct +struct BBox_Tree_Struct final { - BBOX_TREE **Node; // If node: children; if leaf: element + BBox_Tree_Struct **Node; // If node: children; if leaf: element BoundingBox BBox; // Bounding box of this node short Entries; // Number of sub-nodes in this node bool Infinite; // Flag if node is infinite @@ -174,7 +179,7 @@ struct BBox_Tree_Struct typedef bool VECTORB[3]; -class Rayinfo +class Rayinfo final { public: BBoxVector3d origin; ///< Ray's origin. @@ -241,7 +246,7 @@ enum BBoxDirection /// `std::priority_queue` becase we make use of Clear(), an operation /// which `std::priority_queue` does not support. /// -class BBoxPriorityQueue +class BBoxPriorityQueue final { public: @@ -255,13 +260,13 @@ class BBoxPriorityQueue protected: - struct Qelem + struct Qelem final { DBL depth; ConstBBoxTreePtr node; }; - vector mQueue; + std::vector mQueue; }; @@ -270,7 +275,7 @@ class BBoxPriorityQueue ******************************************************************************/ void Build_BBox_Tree(BBOX_TREE **Root, size_t numOfFiniteObjects, BBOX_TREE **&Finite, size_t numOfInfiniteObjects, BBOX_TREE **Infinite, size_t& maxfinitecount); -void Build_Bounding_Slabs(BBOX_TREE **Root, vector& objects, unsigned int& numberOfFiniteObjects, unsigned int& numberOfInfiniteObjects, unsigned int& numberOfLightSources); +void Build_Bounding_Slabs(BBOX_TREE **Root, std::vector& objects, unsigned int& numberOfFiniteObjects, unsigned int& numberOfInfiniteObjects, unsigned int& numberOfLightSources); void Recompute_BBox(BoundingBox *bbox, const TRANSFORM *trans); bool Intersect_BBox_Tree(BBoxPriorityQueue& pqueue, const BBOX_TREE *Root, const Ray& ray, Intersection *Best_Intersection, TraceThreadData *Thread); @@ -294,5 +299,6 @@ inline void BOUNDS_VOLUME(DBL& a, const BoundingBox& b) //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BOUNDINGBOX_H diff --git a/source/core/bounding/boundingbox_fwd.h b/source/core/bounding/boundingbox_fwd.h new file mode 100644 index 000000000..6c8185335 --- /dev/null +++ b/source/core/bounding/boundingbox_fwd.h @@ -0,0 +1,55 @@ +//****************************************************************************** +/// +/// @file core/bounding/boundingbox_fwd.h +/// +/// Forward declarations related to bounding boxes. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_CORE_BOUNDINGBOX_FWD_H +#define POVRAY_CORE_BOUNDINGBOX_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +struct BBox_Tree_Struct; + +using BBOX_TREE = BBox_Tree_Struct; ///< @deprecated +using BBoxTreePtr = BBox_Tree_Struct*; +using ConstBBoxTreePtr = const BBox_Tree_Struct*; + +} +// end of namespace pov + +#endif // POVRAY_CORE_BOUNDINGBOX_FWD_H diff --git a/source/core/bounding/boundingcylinder.cpp b/source/core/bounding/boundingcylinder.cpp index d9b738ee5..e420375d1 100644 --- a/source/core/bounding/boundingcylinder.cpp +++ b/source/core/bounding/boundingcylinder.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -33,9 +33,17 @@ /// //****************************************************************************** -// Module config header file must be the first file included within POV-Ray unit header files +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/bounding/boundingcylinder.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" // this must be the last file included @@ -44,6 +52,8 @@ namespace pov { +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -711,3 +721,4 @@ void Destroy_BCyl(BCYL *BCyl) } } +// end of namespace pov diff --git a/source/core/bounding/boundingcylinder.h b/source/core/bounding/boundingcylinder.h index 1f35527fb..6cf91eb69 100644 --- a/source/core/bounding/boundingcylinder.h +++ b/source/core/bounding/boundingcylinder.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,7 +38,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/bounding/boundingcylinder_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/vector.h" namespace pov @@ -64,24 +75,22 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct BCyl_Struct BCYL; -typedef struct BCyl_Entry_Struct BCYL_ENTRY; -typedef struct BCyl_Intersection_Struct BCYL_INT; - -struct BCyl_Intersection_Struct +struct BCyl_Intersection_Struct final { int n; /* Number of cylinder hit */ DBL d[2]; /* Intersection distance(s) */ DBL w[2]; /* Intersection parameter(s) */ }; +using BCYL_INT = BCyl_Intersection_Struct; ///< @deprecated -struct BCyl_Entry_Struct +struct BCyl_Entry_Struct final { short r1, r2; /* Index of min/max segment radius */ short h1, h2; /* Index of min/max segmnet height */ }; +using BCYL_ENTRY = BCyl_Entry_Struct; ///< @deprecated -struct BCyl_Struct +struct BCyl_Struct final { int number; /* Number of bounding cylinders. */ short nradius; /* Number of different bound-radii. */ @@ -99,12 +108,13 @@ struct BCyl_Struct BCYL *Create_BCyl (int, const DBL *, const DBL *, const DBL *, const DBL *); void Destroy_BCyl (BCYL *); -int Intersect_BCyl (const BCYL *BCyl, vector& Intervals, vector& rint, vector& hint, const Vector3d& P, const Vector3d& D); +int Intersect_BCyl (const BCYL *BCyl, std::vector& Intervals, std::vector& rint, std::vector& hint, const Vector3d& P, const Vector3d& D); /// @} /// //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BOUNDINGCYLINDER_H diff --git a/source/core/bounding/boundingcylinder_fwd.h b/source/core/bounding/boundingcylinder_fwd.h new file mode 100644 index 000000000..15be9cf05 --- /dev/null +++ b/source/core/bounding/boundingcylinder_fwd.h @@ -0,0 +1,53 @@ +//****************************************************************************** +/// +/// @file core/bounding/boundingcylinder_fwd.h +/// +/// Forward declarations related to bounding cylinders (used by lathe and sor). +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_CORE_BOUNDINGCYLINDER_FWD_H +#define POVRAY_CORE_BOUNDINGCYLINDER_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +struct BCyl_Struct; + +using BCYL = BCyl_Struct; ///< @deprecated + +} +// end of namespace pov + +#endif // POVRAY_CORE_BOUNDINGCYLINDER_FWD_H diff --git a/source/core/bounding/boundingsphere.cpp b/source/core/bounding/boundingsphere.cpp index 67b824f5b..2554afaef 100644 --- a/source/core/bounding/boundingsphere.cpp +++ b/source/core/bounding/boundingsphere.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/bounding/boundingsphere.h" +// C++ variants of C standard header files +#include + +// C++ standard header files #include +// POV-Ray header files (base module) +#include "base/pov_mem.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" // this must be the last file included @@ -46,6 +54,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -428,13 +439,13 @@ static int sort_and_split(BSPHERE_TREE **Root, BSPHERE_TREE ***Elements, int *nE switch(Axis) { case X: - QSORT(reinterpret_cast(*Elements + first), size, sizeof(BSPHERE_TREE *), comp_elements); + std::qsort(*Elements + first, size, sizeof(BSPHERE_TREE*), comp_elements); break; case Y: - QSORT(reinterpret_cast(*Elements + first), size, sizeof(BSPHERE_TREE *), comp_elements); + std::qsort(*Elements + first, size, sizeof(BSPHERE_TREE*), comp_elements); break; case Z: - QSORT(reinterpret_cast(*Elements + first), size, sizeof(BSPHERE_TREE *), comp_elements); + std::qsort(*Elements + first, size, sizeof(BSPHERE_TREE*), comp_elements); break; } @@ -647,3 +658,4 @@ void Destroy_Bounding_Sphere_Hierarchy(BSPHERE_TREE *Node) } } +// end of namespace pov diff --git a/source/core/bounding/boundingsphere.h b/source/core/bounding/boundingsphere.h index a0b7c792d..936c1d5d8 100644 --- a/source/core/bounding/boundingsphere.h +++ b/source/core/bounding/boundingsphere.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/vector.h" namespace pov @@ -55,15 +63,14 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct BSphere_Tree_Struct BSPHERE_TREE; - -struct BSphere_Tree_Struct +struct BSphere_Tree_Struct final { short Entries; /* Number of components (node if 0) */ Vector3d C; /* Center of bounding sphere */ DBL r2; /* Radius^2 of bounding sphere */ - BSPHERE_TREE **Node; /* if node: children; if leaf: element */ + BSphere_Tree_Struct **Node; /* if node: children; if leaf: element */ }; +using BSPHERE_TREE = BSphere_Tree_Struct; ///< @deprecated /***************************************************************************** @@ -78,5 +85,6 @@ void Destroy_Bounding_Sphere_Hierarchy (BSPHERE_TREE *Node); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BOUNDINGSPHERE_H diff --git a/source/core/bounding/bsptree.cpp b/source/core/bounding/bsptree.cpp index 241788229..b9aa0b847 100644 --- a/source/core/bounding/bsptree.cpp +++ b/source/core/bounding/bsptree.cpp @@ -36,11 +36,23 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/bounding/bsptree.h" -#include +// C++ variants of C standard header files +#if BSP_WRITEBOUNDS || BSP_READNODES || BSP_WRITETREE +#include +#endif + +// C++ standard header files +#include #include +#if BSP_WRITEBOUNDS || BSP_READNODES || BSP_WRITETREE +#include +#endif +// POV-Ray header files (base module) +#include "base/stringutilities.h" #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/render/ray.h" #include "core/shape/box.h" @@ -50,6 +62,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + #ifndef BSP_READNODES #define BSP_READNODES 0 #endif @@ -71,6 +87,17 @@ namespace pov const unsigned int NODE_PROGRESS_INTERVAL = 1000; +//****************************************************************************** + +void BSPTree::Mailbox::clear() +{ + count = 0; + // using memset here as std::fill may not be fast with every standard libaray [trf] + std::memset(objects.data(), 0, objects.size() * sizeof(unsigned int)); +} + +//****************************************************************************** + // we allow the values to be set by users to promote experimentation with tree // building. at a later date we may remove this facility since using compile-time // constants is more efficient. @@ -281,11 +308,11 @@ void BSPTree::build(const Progress& progress, const Objects& objects, splits[Z].resize(objects.size() * 2); #if BSP_WRITEBOUNDS || BSP_READNODES || BSP_WRITETREE - string tempstr = UCS2toSysString(inputFile); + std::string tempstr = UCS2toSysString(inputFile); if (tempstr.empty() == true) tempstr = "default"; - string::size_type pos = tempstr.find_last_of('.'); - if (pos != string::npos) + std::string::size_type pos = tempstr.find_last_of('.'); + if (pos != std::string::npos) tempstr.erase(pos); #endif @@ -896,6 +923,7 @@ void BSPTree::ReadRecursive(const Progress& progress, FILE *infile, unsigned int } } +//****************************************************************************** BSPIntersectFunctor::BSPIntersectFunctor(Intersection& bi, const Ray& r, vector& objs, TraceThreadData *t) : found(false), @@ -933,6 +961,7 @@ bool BSPIntersectFunctor::operator()() const return found; } +//****************************************************************************** BSPIntersectCondFunctor::BSPIntersectCondFunctor(Intersection& bi, const Ray& r, vector& objs, TraceThreadData *t, const RayObjectCondition& prec, const RayObjectCondition& postc) : @@ -977,6 +1006,7 @@ bool BSPIntersectCondFunctor::operator()() const return found; } +//****************************************************************************** BSPInsideCondFunctor::BSPInsideCondFunctor(Vector3d o, vector& objs, TraceThreadData *t, const PointObjectCondition& prec, const PointObjectCondition& postc) : @@ -1004,4 +1034,7 @@ bool BSPInsideCondFunctor::operator()() const return found; } +//****************************************************************************** + } +// end of namespace pov diff --git a/source/core/bounding/bsptree.h b/source/core/bounding/bsptree.h index 3523a31d5..8efe5c703 100644 --- a/source/core/bounding/bsptree.h +++ b/source/core/bounding/bsptree.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,10 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include -#include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" namespace pov @@ -55,16 +61,16 @@ namespace pov /// /// @{ -class BSPTree +class BSPTree final { public: - class Mailbox + class Mailbox final { friend class BSPTree; public: inline Mailbox(unsigned int range) : objects((range >> 5) + 1), count(0) { } - inline void clear() { count = 0; memset(&objects[0], 0, objects.size() * sizeof(unsigned int)); } // using memset here as std::fill may not be fast with every standard libaray [trf] + void clear(); inline unsigned int size() const { return count; } inline bool insert(unsigned int i) @@ -79,12 +85,11 @@ class BSPTree } private: /// bit marking object (by index) in mailbox - vector objects; + std::vector objects; /// number of objects in mailbox unsigned int count; - /// unavailable - Mailbox(); + Mailbox() = delete; }; class Objects @@ -142,7 +147,7 @@ class BSPTree private: - struct Node + struct Node final { enum NodeType { @@ -181,7 +186,7 @@ class BSPTree }; }; - struct Split + struct Split final { enum Side { @@ -201,13 +206,13 @@ class BSPTree inline bool operator<(const Split& r) const { return (plane < r.plane); } - struct CompareIndex + struct CompareIndex final { inline bool operator()(const Split& left, const Split& right) const { return (left.index < right.index); } }; }; - struct TraceStack + struct TraceStack final { unsigned int inode; float rentry; @@ -215,11 +220,11 @@ class BSPTree }; /// array of all nodes - vector nodes; + std::vector nodes; /// array of all object pointer lists - vector lists; + std::vector lists; /// splits, only used while building tree - vector splits[3]; + std::vector splits[3]; /// lower left corner of bounding box Vector3d bmin; /// upper right corner of bounding box @@ -253,7 +258,7 @@ class BSPTree /// tree depth counter POV_LONG treeDepthCounter; /// object index list (only used while building tree) - vector indices; + std::vector indices; void BuildRecursive(const Progress& progress, const Objects& objects, unsigned int inode, unsigned int indexbegin, unsigned int indexend, MinMaxBoundingBox& cell, unsigned int maxlevel); void SetObjectNode(unsigned int inode, unsigned int indexbegin, unsigned int indexend); @@ -264,18 +269,18 @@ class BSPTree }; -class BSPIntersectFunctor : public BSPTree::Intersect +class BSPIntersectFunctor final : public BSPTree::Intersect { public: - BSPIntersectFunctor(Intersection& bi, const Ray& r, vector& objs, TraceThreadData *t); - virtual bool operator()(unsigned int index, double& maxdist); - virtual bool operator()() const; + BSPIntersectFunctor(Intersection& bi, const Ray& r, std::vector& objs, TraceThreadData *t); + virtual bool operator()(unsigned int index, double& maxdist) override; + virtual bool operator()() const override; private: bool found; - vector& objects; + std::vector& objects; Intersection& bestisect; const Ray& ray; BBoxVector3d origin; @@ -284,19 +289,19 @@ class BSPIntersectFunctor : public BSPTree::Intersect TraceThreadData *traceThreadData; }; -class BSPIntersectCondFunctor : public BSPTree::Intersect +class BSPIntersectCondFunctor final : public BSPTree::Intersect { public: - BSPIntersectCondFunctor(Intersection& bi, const Ray& r, vector& objs, TraceThreadData *t, + BSPIntersectCondFunctor(Intersection& bi, const Ray& r, std::vector& objs, TraceThreadData *t, const RayObjectCondition& prec, const RayObjectCondition& postc); - virtual bool operator()(unsigned int index, double& maxdist); - virtual bool operator()() const; + virtual bool operator()(unsigned int index, double& maxdist) override; + virtual bool operator()() const override; private: bool found; - vector& objects; + std::vector& objects; Intersection& bestisect; const Ray& ray; BBoxVector3d origin; @@ -307,19 +312,19 @@ class BSPIntersectCondFunctor : public BSPTree::Intersect const RayObjectCondition& postcondition; }; -class BSPInsideCondFunctor : public BSPTree::Inside +class BSPInsideCondFunctor final : public BSPTree::Inside { public: - BSPInsideCondFunctor(Vector3d o, vector& objs, TraceThreadData *t, + BSPInsideCondFunctor(Vector3d o, std::vector& objs, TraceThreadData *t, const PointObjectCondition& prec, const PointObjectCondition& postc); - virtual bool operator()(unsigned int index); - virtual bool operator()() const; + virtual bool operator()(unsigned int index) override; + virtual bool operator()() const override; private: bool found; - vector& objects; + std::vector& objects; Vector3d origin; const PointObjectCondition& precondition; const PointObjectCondition& postcondition; @@ -331,5 +336,6 @@ class BSPInsideCondFunctor : public BSPTree::Inside //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BSPTREE_H diff --git a/source/core/colour/spectral.cpp b/source/core/colour/spectral.cpp index f4aa709a0..3c9083419 100644 --- a/source/core/colour/spectral.cpp +++ b/source/core/colour/spectral.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,9 +36,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/colour/spectral.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) #include "base/colour.h" #include "base/mathutil.h" +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -376,7 +386,7 @@ static RGBColour SpectralHueIntegral[SPECTRAL_HUE_TABLE_SIZE] = { MathColour SpectralBand::GetHueIntegral(double wavelength) { double tableOffset = clip((wavelength-SPECTRAL_HUE_TABLE_BASE)/SPECTRAL_HUE_TABLE_STEP, 0.0, SPECTRAL_HUE_TABLE_SIZE-1.0); - int tableIndex = min((int)tableOffset, SPECTRAL_HUE_TABLE_SIZE-2); + int tableIndex = std::min((int)tableOffset, SPECTRAL_HUE_TABLE_SIZE-2); tableOffset -= tableIndex; return ToMathColour((1.0-tableOffset) * SpectralHueIntegral[tableIndex] + tableOffset * SpectralHueIntegral[tableIndex+1]); } @@ -384,3 +394,4 @@ MathColour SpectralBand::GetHueIntegral(double wavelength) #endif } +// end of namespace pov diff --git a/source/core/colour/spectral.h b/source/core/colour/spectral.h index d9eca453f..f7de1e0a0 100644 --- a/source/core/colour/spectral.h +++ b/source/core/colour/spectral.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/colour.h" +// POV-Ray header files (core module) +// (none at the moment) + namespace pov { @@ -59,7 +67,7 @@ using namespace pov_base; #define SPECTRAL_CENTER ((SPECTRAL_VIOLET + SPECTRAL_RED)/2) // TODO - maybe should define this as yellow /// Class representing a spectral band. -class SpectralBand +class SpectralBand final { public: /// Default Constructor. @@ -120,6 +128,7 @@ class SpectralBand }; } +// end of namespace pov namespace pov_base { @@ -158,5 +167,6 @@ RGBColour FromRGB(const MathColour& col); //############################################################################## } +// end of namespace pov_base #endif // POVRAY_CORE_SPECTRAL_H diff --git a/source/core/configcore.h b/source/core/configcore.h index bee21bdde..284b0f3bb 100644 --- a/source/core/configcore.h +++ b/source/core/configcore.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -42,9 +42,6 @@ #include "base/configbase.h" #include "syspovconfigcore.h" -// C++ variants of C standard header files -#include - //############################################################################## /// /// @defgroup PovCoreConfig Core Compile-Time Configuration @@ -204,10 +201,6 @@ /// //****************************************************************************** -#ifndef QSORT - #define QSORT(a,b,c,d) std::qsort((a),(b),(c),(d)) -#endif - /// @def TRY_OPTIMIZED_NOISE /// Whether the platform provides dynamic optimized noise. /// @@ -227,6 +220,53 @@ #endif #endif +/// @def C99_COMPATIBLE_RADIOSITY +/// @deprecated +/// This is effectively a legacy alias for @ref POV_PORTABLE_RADIOSITY, +/// which takes precedence if defined. +/// +#ifndef C99_COMPATIBLE_RADIOSITY + #define C99_COMPATIBLE_RADIOSITY 0 +#endif + +/// @def POV_PORTABLE_RADIOSITY +/// Whether to implement radiosity octree in a portable manner. +/// +/// This setting selects one of several implementations of certain operations +/// in the octree code: +/// +/// - @ref Pow2Floor(): Rounds a positive value down towards the next lower +/// power of 2. +/// - @ref BiasedIntLog2(): Computes the (biased) integer base-2 logarithm +/// of a positive value. +/// - @ref BiasedIntPow2(): Computes 2 to a (biased) integer ppwer. +/// +/// The available implementations are based on the following primitives: +/// +/// | Value | `Pow2Floor` | `BiasedIntLog2` | `BiasedIntPow2` | Bias | Prerequisites | +/// | ----: | :---------------------------- | :-------- | :-------------------- | ----: | :------------------------------------ | +/// | 0 | `float` bit bashing ||| +127 | `float` must be IEEE 754 "binary32" | +/// | 1 | `logbf`, `pow` | `logbf` | `int` bit shifting | 0 | `float` must be radix-2 | +/// | 2 | `ilogbf`, `int` bit shifting | `ilogbf` | ^ | ^ | ^ | +/// | 3 | `logb`, `pow` | `logb` | ^ | ^ | `double` must be radix-2 | +/// | 4 | `ilogb`, `int` bit shifting | `ilogb` | ^ | ^ | ^ | +/// | 5 | `double` bit bashing ||| +1023 | `double` must be IEEE 754 "binary64" | +/// | 6 | `frexpf`, `ldexpf` | `frexpf` | `ldexpf` | 0 | none | +/// | 7 | `ilogbf`, `ldexpf` | `ilogbf` | `ldexpf` | ^ | `float` must be radix-2 | +/// | 8 | `frexp`, `ldexp` | `frexp` | `ldexp` | ^ | none | +/// | 9 | `ilogb`, `ldexp` | `ilogb` | `ldexp` | ^ | `double` must be radix-2 | +/// +/// @note +/// Settings 1-4 are deprecated, due to their restricted numeric range. +/// +/// @note +/// This setting defaults to @ref C99_COMPATIBLE_RADIOSITY, which in turn +/// defaults to 0. +/// +#ifndef POV_PORTABLE_RADIOSITY + #define POV_PORTABLE_RADIOSITY C99_COMPATIBLE_RADIOSITY +#endif + //****************************************************************************** /// /// @name Debug Settings. diff --git a/source/core/core_fwd.h b/source/core/core_fwd.h new file mode 100644 index 000000000..28fe8da7f --- /dev/null +++ b/source/core/core_fwd.h @@ -0,0 +1,65 @@ +//****************************************************************************** +/// +/// @file core/core_fwd.h +/// +/// Forward declarations of core module referenced by other modules. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_CORE_FWD_H +#define POVRAY_CORE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class Interior; + +class Intersection; + +class LightSource; + +class ObjectBase; +using ObjectPtr = ObjectBase*; +using ConstObjectPtr = const ObjectBase*; + +class PhotonShootingUnit; + +class SceneData; + +class TraceThreadData; + +} +// end of namespace pov + +#endif // POVRAY_CORE_FWD_H diff --git a/source/core/coretypes.h b/source/core/coretypes.h index fb09e243f..f075ee7b0 100644 --- a/source/core/coretypes.h +++ b/source/core/coretypes.h @@ -36,16 +36,31 @@ #ifndef POVRAY_CORE_CORETYPES_H #define POVRAY_CORE_CORETYPES_H +// Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/core_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +#include +#include + +// Boost header files +#include +// POV-Ray header files (base module) #include "base/colour.h" #include "base/messenger.h" -#include "base/types.h" -#include "base/textstream.h" +#include "base/povassert.h" +#include "base/stringtypes.h" +// POV-Ray header files (core module) #include "core/math/vector.h" +#include "core/render/ray_fwd.h" namespace pov { @@ -58,10 +73,6 @@ namespace pov using namespace pov_base; -// from ; we don't want to always type the namespace for these. -using std::min; -using std::max; - // from ; we don't want to always type the namespace for these. using std::abs; using std::acos; @@ -94,11 +105,8 @@ inline T Sqr(T a) return a * a; } -class ObjectBase; -typedef ObjectBase * ObjectPtr; -typedef const ObjectBase * ConstObjectPtr; - -typedef struct Transform_Struct TRANSFORM; +struct Transform_Struct; +using TRANSFORM = Transform_Struct; ///< @deprecated /// @} /// @@ -108,11 +116,17 @@ typedef struct Transform_Struct TRANSFORM; /// /// @{ -typedef struct Pattern_Struct TPATTERN; -typedef struct Texture_Struct TEXTURE; -typedef struct Pigment_Struct PIGMENT; -typedef struct Tnormal_Struct TNORMAL; -typedef struct Finish_Struct FINISH; +struct Pattern_Struct; +struct Texture_Struct; +struct Pigment_Struct; +struct Tnormal_Struct; +struct Finish_Struct; + +using TPATTERN = Pattern_Struct; ///< @deprecated +using TEXTURE = Texture_Struct; ///< @deprecated +using PIGMENT = Pigment_Struct; ///< @deprecated +using TNORMAL = Tnormal_Struct; ///< @deprecated +using FINISH = Finish_Struct; ///< @deprecated typedef TEXTURE* TexturePtr; @@ -124,7 +138,7 @@ typedef TEXTURE* TexturePtr; /// /// @{ -class Media +class Media final { public: int Type; @@ -154,7 +168,7 @@ class Media DBL AA_Threshold; int AA_Level; - vector Density; + std::vector Density; Media(); Media(const Media&); @@ -176,7 +190,7 @@ class Media /// @{ class SubsurfaceInterior; -class Interior +class Interior final { public: int hollow, Disp_NElems; @@ -184,8 +198,8 @@ class Interior SNGL Caustics, Old_Refract; SNGL Fade_Distance, Fade_Power; MathColour Fade_Colour; - vector media; - shared_ptr subsurface; + std::vector media; + std::shared_ptr subsurface; Interior(); Interior(const Interior&); @@ -195,11 +209,12 @@ class Interior void PostProcess(); private: - Interior& operator=(const Interior&); + + Interior& operator=(const Interior&) = delete; }; -typedef shared_ptr InteriorPtr; -typedef shared_ptr ConstInteriorPtr; +typedef std::shared_ptr InteriorPtr; +typedef std::shared_ptr ConstInteriorPtr; /// @} /// @@ -211,8 +226,8 @@ typedef shared_ptr ConstInteriorPtr; struct BasicPattern; -typedef shared_ptr PatternPtr; -typedef shared_ptr ConstPatternPtr; +typedef std::shared_ptr PatternPtr; +typedef std::shared_ptr ConstPatternPtr; struct Pattern_Struct @@ -230,47 +245,44 @@ struct Pattern_Struct /// /// @{ -typedef struct Material_Struct MATERIAL; - -struct Material_Struct +struct Material_Struct final { TEXTURE *Texture; TEXTURE *Interior_Texture; InteriorPtr interior; }; - -class LightSource; +using MATERIAL = Material_Struct; ///< @deprecated template -class RefPool +class RefPool final { public: RefPool() { } - ~RefPool() { for(typename vector::iterator i(pool.begin()); i != pool.end(); i++) delete *i; pool.clear(); } + ~RefPool() { for(typename std::vector::iterator i(pool.begin()); i != pool.end(); i++) delete *i; pool.clear(); } T *alloc() { if(pool.empty()) return new T(); T *ptr(pool.back()); pool.pop_back(); return ptr; } void release(T *ptr) { pool.push_back(ptr); } private: - vector pool; + std::vector pool; - RefPool(const RefPool&); - RefPool& operator=(RefPool&); + RefPool(const RefPool&) = delete; + RefPool& operator=(RefPool&) = delete; }; template -struct RefClearDefault +struct RefClearDefault final { void operator()(T&) { } }; template -struct RefClearContainer +struct RefClearContainer final { void operator()(T& p) { p.clear(); } }; -template > -class Ref +template> +class Ref final { public: Ref(RefPool& p) : pool(p), ptr(p.alloc()) { } @@ -285,12 +297,12 @@ class Ref RefPool& pool; T *ptr; - Ref(); - Ref(const Ref&); - Ref& operator=(Ref&); + Ref() = delete; + Ref(const Ref&) = delete; + Ref& operator=(Ref&) = delete; }; -class ObjectDebugHelper +class ObjectDebugHelper final { public: int Index; @@ -320,7 +332,7 @@ typedef unsigned short HF_VAL; /// /// This class holds various information on a ray-object intersection. /// -class Intersection +class Intersection final { public: @@ -443,7 +455,7 @@ class Intersection ~Intersection() { } }; -typedef std::stack > IStackData; +typedef std::stack> IStackData; typedef RefPool IStackPool; typedef Ref IStack; @@ -470,26 +482,26 @@ struct BasicRay struct TraceTicket; -class Ray; - struct RayObjectCondition { + virtual ~RayObjectCondition() {} virtual bool operator()(const Ray& ray, ConstObjectPtr object, DBL data) const = 0; }; -struct TrueRayObjectCondition : public RayObjectCondition +struct TrueRayObjectCondition final : public RayObjectCondition { - virtual bool operator()(const Ray&, ConstObjectPtr, DBL) const { return true; } + virtual bool operator()(const Ray&, ConstObjectPtr, DBL) const override { return true; } }; struct PointObjectCondition { + virtual ~PointObjectCondition() {} virtual bool operator()(const Vector3d& point, ConstObjectPtr object) const = 0; }; -struct TruePointObjectCondition : public PointObjectCondition +struct TruePointObjectCondition final : public PointObjectCondition { - virtual bool operator()(const Vector3d&, ConstObjectPtr) const { return true; } + virtual bool operator()(const Vector3d&, ConstObjectPtr) const override { return true; } }; /// @} @@ -500,7 +512,7 @@ struct TruePointObjectCondition : public PointObjectCondition /// /// @{ -struct FrameSettings +struct FrameSettings final { DBL Clock_Value; // May change between frames of an animation int FrameNumber; // May change between frames of an animation @@ -541,9 +553,9 @@ class FractalRules virtual bool Bound (const BasicRay&, const Fractal *, DBL *, DBL *) const = 0; }; -typedef shared_ptr FractalRulesPtr; +typedef std::shared_ptr FractalRulesPtr; -struct QualityFlags +struct QualityFlags final { bool ambientOnly : 1; bool quickColour : 1; @@ -581,8 +593,6 @@ struct QualityFlags /// /// @{ -class TraceThreadData; - class GenericFunctionContext { public: @@ -607,8 +617,8 @@ class GenericFunctionContextFactory inline void intrusive_ptr_add_ref(GenericFunctionContextFactory* f) { ++f->mRefCounter; } inline void intrusive_ptr_release(GenericFunctionContextFactory* f) { if (!(--f->mRefCounter)) delete f; } -typedef intrusive_ptr GenericFunctionContextFactoryIPtr; -typedef GenericFunctionContextFactory* GenericFunctionContextFactoryTPtr; +typedef boost::intrusive_ptr GenericFunctionContextFactoryIPtr; +typedef GenericFunctionContextFactory* GenericFunctionContextFactoryTPtr; struct SourcePosition { @@ -658,7 +668,7 @@ typedef GenericCustomFunction GenericScalarFunction; typedef GenericScalarFunction* GenericScalarFunctionPtr; template -class GenericCustomFunctionInstance +class GenericCustomFunctionInstance final { public: inline GenericCustomFunctionInstance(GenericCustomFunction* pFn, TraceThreadData* pThreadData) : @@ -730,7 +740,8 @@ class GenericCustomFunctionInstance bool mReInit; private: - GenericCustomFunctionInstance(); + + GenericCustomFunctionInstance() = delete; }; typedef GenericCustomFunctionInstance GenericScalarFunctionInstance; @@ -741,5 +752,6 @@ typedef GenericScalarFunctionInstance* GenericScalarFunctionInstancePtr; //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_CORETYPES_H diff --git a/source/core/lighting/lightgroup.cpp b/source/core/lighting/lightgroup.cpp index db1a42ec3..ae4b228c5 100644 --- a/source/core/lighting/lightgroup.cpp +++ b/source/core/lighting/lightgroup.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/lighting/lightgroup.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/lighting/lightsource.h" #include "core/scene/object.h" #include "core/shape/csg.h" @@ -46,6 +56,8 @@ namespace pov { +using std::vector; + void Promote_Local_Lights_Recursive(CompoundObject *Object, vector& Lights); @@ -252,3 +264,4 @@ bool Check_Photon_Light_Group(ConstObjectPtr Object) } } +// end of namespace pov diff --git a/source/core/lighting/lightgroup.h b/source/core/lighting/lightgroup.h index dc251ff0e..0b0f9b46c 100644 --- a/source/core/lighting/lightgroup.h +++ b/source/core/lighting/lightgroup.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,7 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" +#include "core/shape/csg_fwd.h" namespace pov { @@ -51,8 +60,6 @@ namespace pov /// /// @{ -class CSG; - void Promote_Local_Lights(CSG *Object); bool Check_Photon_Light_Group(ConstObjectPtr Object); @@ -61,5 +68,6 @@ bool Check_Photon_Light_Group(ConstObjectPtr Object); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_LIGHTGROUP_H diff --git a/source/core/lighting/lightsource.cpp b/source/core/lighting/lightsource.cpp index 8e34015e2..c4b86c8aa 100644 --- a/source/core/lighting/lightsource.cpp +++ b/source/core/lighting/lightsource.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/lighting/lightsource.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/object.h" @@ -657,3 +665,4 @@ void LightSource::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThre } } +// end of namespace pov diff --git a/source/core/lighting/lightsource.h b/source/core/lighting/lightsource.h index efe9b747d..dd4ef7289 100644 --- a/source/core/lighting/lightsource.h +++ b/source/core/lighting/lightsource.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/core_fwd.h" +#include "core/render/ray_fwd.h" + namespace pov { @@ -49,9 +60,6 @@ namespace pov /// /// @{ -class LightSource; -class Ray; - //****************************************************************************** /// /// @name Object Types @@ -87,5 +95,6 @@ DBL cubic_spline(DBL low,DBL high,DBL pos); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_LIGHTSOURCE_H diff --git a/source/core/lighting/photons.cpp b/source/core/lighting/photons.cpp index 08ed3c83b..b54dfe633 100644 --- a/source/core/lighting/photons.cpp +++ b/source/core/lighting/photons.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -43,6 +43,9 @@ #include #include +// POV-Ray header files (base module) +#include "base/povassert.h" + // POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" @@ -70,6 +73,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + /* ------------------------------------------------------ */ /* global variables */ /* ------------------------------------------------------ */ @@ -92,7 +99,7 @@ constexpr int PHOTON_BLOCK_MASK = PHOTON_BLOCK_SIZE - 1; static_assert(PHOTON_BLOCK_POWER < std::numeric_limits::digits, "PHOTON_BLOCK_POWER too large"); -class PhotonMap::PhotonBlock +class PhotonMap::PhotonBlock final { public: inline Photon& operator[](size_t i) @@ -110,7 +117,7 @@ class PhotonMap::PhotonBlock //****************************************************************************** -PhotonTrace::PhotonTrace(shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, Trace::CooperateFunctor& cf) : +PhotonTrace::PhotonTrace(std::shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, Trace::CooperateFunctor& cf) : Trace(sd, td, qf, cf, mediaPhotons, noRadiosity), mediaPhotons(sd, td, this, new PhotonGatherer(&sd->mediaPhotonMap, sd->photonSettings)) { @@ -932,7 +939,7 @@ void PhotonTrace::addSurfacePhoton(const Vector3d& Point, const Vector3d& Origin } -PhotonMediaFunction::PhotonMediaFunction(shared_ptr sd, TraceThreadData *td, Trace *t, PhotonGatherer *pg) : +PhotonMediaFunction::PhotonMediaFunction(std::shared_ptr sd, TraceThreadData *td, Trace *t, PhotonGatherer *pg) : MediaFunction(td, t, pg), sceneData(sd) { @@ -2624,7 +2631,7 @@ int LightTargetCombo::computeMergedFlags() } -void LightTargetCombo::computeAnglesAndDeltas(shared_ptr sceneData) +void LightTargetCombo::computeAnglesAndDeltas(std::shared_ptr sceneData) { shootingDirection.compute(); @@ -2683,5 +2690,5 @@ void LightTargetCombo::computeAnglesAndDeltas(shared_ptr sceneData) } } -} // end of namespace - +} +// end of namespace pov diff --git a/source/core/lighting/photons.h b/source/core/lighting/photons.h index 8937e6712..e58fcb1a8 100644 --- a/source/core/lighting/photons.h +++ b/source/core/lighting/photons.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,9 +38,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/lighting/photons_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) // C++ standard header files +#include #include +#include + +// POV-Ray header files (base module) +// (none at the moment) // POV-Ray header files (core module) #include "core/material/media.h" @@ -61,7 +70,7 @@ using namespace pov_base; #define MEDIA_INTERACTION 1 /* ------------------------------------------------------ */ -class ScenePhotonSettings +class ScenePhotonSettings final { public: ScenePhotonSettings() @@ -156,7 +165,7 @@ class ScenePhotonSettings typedef float PhotonScalar; typedef GenericVector3d PhotonVector3d; -struct Photon +struct Photon final { void init(unsigned char _info) { @@ -173,7 +182,7 @@ struct Photon /* photon map */ /* ------------------------------------------------------ */ -class PhotonMap +class PhotonMap final { private: @@ -257,7 +266,7 @@ typedef Photon* PhotonPtr; /* ------------------------------------------------------ */ /* photon gatherer */ /* ------------------------------------------------------ */ -class GatheredPhotons +class GatheredPhotons final { public: // priority queue arrays @@ -271,7 +280,7 @@ class GatheredPhotons ~GatheredPhotons(); }; -class PhotonGatherer +class PhotonGatherer final { public: ScenePhotonSettings& photonSettings; @@ -301,30 +310,30 @@ class PhotonGatherer void FullPQInsert(Photon *photon, DBL d); }; -class PhotonMediaFunction : public MediaFunction +class PhotonMediaFunction final : public MediaFunction { public: - PhotonMediaFunction(shared_ptr sd, TraceThreadData *td, Trace *t, PhotonGatherer *pg); + PhotonMediaFunction(std::shared_ptr sd, TraceThreadData *td, Trace *t, PhotonGatherer *pg); void ComputeMediaAndDepositPhotons(MediaVector& medias, const Ray& ray, const Intersection& isect, MathColour& colour); protected: void DepositMediaPhotons(MathColour& colour, MediaVector& medias, LightSourceEntryVector& lights, MediaIntervalVector& mediaintervals, const Ray& ray, int minsamples, bool ignore_photons, bool use_scattering, bool all_constant_and_light_ray); private: - shared_ptr sceneData; + std::shared_ptr sceneData; void addMediaPhoton(const Vector3d& Point, const Vector3d& Origin, const MathColour& LightCol, DBL depthDiff); }; -class PhotonTrace : public Trace +class PhotonTrace final : public Trace { public: - PhotonTrace(shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, Trace::CooperateFunctor& cf); - ~PhotonTrace(); + PhotonTrace(std::shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, Trace::CooperateFunctor& cf); + virtual ~PhotonTrace() override; - virtual DBL TraceRay(Ray& ray, MathColour& colour, ColourChannel&, COLC weight, bool continuedRay, DBL maxDepth = 0.0); + virtual DBL TraceRay(Ray& ray, MathColour& colour, ColourChannel&, COLC weight, bool continuedRay, DBL maxDepth = 0.0) override; protected: - virtual void ComputeLightedTexture(MathColour& LightCol, ColourChannel&, const TEXTURE *Texture, vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, Ray& ray, COLC weight, Intersection& isect); + virtual void ComputeLightedTexture(MathColour& LightCol, ColourChannel&, const TEXTURE *Texture, std::vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, Ray& ray, COLC weight, Intersection& isect) override; bool ComputeRefractionForPhotons(const FINISH* finish, Interior *interior, const Vector3d& ipoint, Ray& ray, const Vector3d& normal, const Vector3d& rawnormal, MathColour& colour, COLC weight); bool TraceRefractionRayForPhotons(const FINISH* finish, const Vector3d& ipoint, Ray& ray, Ray& nray, DBL ior, DBL n, const Vector3d& normal, const Vector3d& rawnormal, const Vector3d& localnormal, MathColour& colour, COLC weight); private: @@ -334,14 +343,11 @@ class PhotonTrace : public Trace void addSurfacePhoton(const Vector3d& Point, const Vector3d& Origin, const MathColour& LightCol); }; -// forward declaration -class LightTargetCombo; - /* ------------------------------------------------------ */ /* photon map builder */ /* ------------------------------------------------------ */ -class ShootingDirection +class ShootingDirection final { public: ShootingDirection(LightSource* light, ObjectPtr target):light(light),target(target) {} @@ -357,7 +363,7 @@ class ShootingDirection }; -class LightTargetCombo +class LightTargetCombo final { public: LightTargetCombo(LightSource *light, ObjectPtr target):light(light),target(target),shootingDirection(light,target) {} @@ -371,11 +377,11 @@ class LightTargetCombo ShootingDirection shootingDirection; int computeMergedFlags(); - void computeAnglesAndDeltas(shared_ptr sceneData); + void computeAnglesAndDeltas(std::shared_ptr sceneData); }; -class PhotonShootingUnit +class PhotonShootingUnit final { public: PhotonShootingUnit(LightSource* light, ObjectPtr target):lightAndObject(light,target) {} @@ -385,7 +391,7 @@ class PhotonShootingUnit -class SinCosOptimizations +class SinCosOptimizations final { public: // speed optimization data - sin/cos stored in two arrays @@ -411,5 +417,6 @@ void ChooseRay(BasicRay &NewRay, const Vector3d& Normal, const Vector3d& Raw_Nor //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PHOTONS_H diff --git a/source/core/lighting/photons_fwd.h b/source/core/lighting/photons_fwd.h new file mode 100644 index 000000000..3b874b44a --- /dev/null +++ b/source/core/lighting/photons_fwd.h @@ -0,0 +1,53 @@ +//****************************************************************************** +/// +/// @file core/lighting/photons_fwd.h +/// +/// Forward declarations related to Photon Mapping. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_CORE_PHOTONS_FWD_H +#define POVRAY_CORE_PHOTONS_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class LightTargetCombo; +class PhotonMap; +class PhotonTrace; + +} +// end of namespace pov + +#endif // POVRAY_CORE_PHOTONS_FWD_H diff --git a/source/core/lighting/radiosity.cpp b/source/core/lighting/radiosity.cpp index df9956184..f90aa086f 100644 --- a/source/core/lighting/radiosity.cpp +++ b/source/core/lighting/radiosity.cpp @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -63,11 +63,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/lighting/radiosity.h" +// C++ variants of C standard header files #include + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/lighting/photons.h" #include "core/render/ray.h" #include "core/scene/scenedata.h" @@ -82,6 +88,9 @@ namespace pov using namespace pov_base; +using std::min; +using std::max; + // #define RAD_GRADIENT 1 // [CLi] gradient seems to provide no gain at best, and may actually cause artifacts // #define SAW_METHOD 1 // #define SAW_METHOD_ROOT 2 @@ -106,7 +115,7 @@ const int PRETRACE_STEP_LOADED = std::numeric_limits::max(); // d #define BRILLIANCE_EPSILON 1e-5 // structure used to gather weighted average during tree traversal -struct WT_AVG +struct WT_AVG final { MathColour Weights_Times_Illuminances; // Aggregates during traversal DBL Weights; // Aggregates during traversal @@ -152,7 +161,7 @@ inline QualityFlags GetRadiosityQualityFlags(const SceneRadiositySettings& rs, c static const unsigned int BLOCK_POOL_UNIT_SIZE = 32; -struct RadiosityCache::BlockPool::PoolUnit +struct RadiosityCache::BlockPool::PoolUnit final { PoolUnit *next; ot_block_struct blocks[BLOCK_POOL_UNIT_SIZE]; @@ -284,7 +293,7 @@ RadiosityRecursionSettings* SceneRadiositySettings::GetRecursionSettings(bool fi return recSettings; } -RadiosityFunction::RadiosityFunction(shared_ptr sd, TraceThreadData *td, const SceneRadiositySettings& rs, +RadiosityFunction::RadiosityFunction(std::shared_ptr sd, TraceThreadData *td, const SceneRadiositySettings& rs, RadiosityCache& rc, Trace::CooperateFunctor& cf, bool ft, const Vector3d& camera) : threadData(td), trace(sd, td, GetRadiosityQualityFlags(rs, QualityFlags(9)), cf, media, *this), // TODO FIXME - the only reason we can safely hard-code level-9 quality here is because radiosity happens to be disabled at lower settings @@ -1239,19 +1248,6 @@ ot_node_struct *RadiosityCache::GetNode(RenderStatistics* stats, const ot_id_str // If there is no root yet, create one. This is a first-time-through if (octree.root == nullptr) { - // CLi moved C99_COMPATIBLE_RADIOSITY check from ot_newroot() to ot_ins() `nullptr` root handling section - // (no need to do this again and again for every new node inserted) -#if(C99_COMPATIBLE_RADIOSITY == 0) - if((sizeof(int) != 4) || (sizeof(float) != 4)) - { - throw POV_EXCEPTION_STRING("Radiosity is not available in this unofficial version because\n" - "the person who made this unofficial version available did not\n" - "properly check for compatibility on your platform.\n" - "Look for C99_COMPATIBLE_RADIOSITY in the source code to find\n" - "out how to correct this."); - } -#endif - // now is the time to lock the tree for modification #if POV_MULTITHREADED treeLock.lock(); @@ -1771,4 +1767,5 @@ bool RadiosityCache::AverageNearBlock(ot_block_struct *block, void *void_info) return true; } -} // end of namespace +} +// end of namespace pov diff --git a/source/core/lighting/radiosity.h b/source/core/lighting/radiosity.h index 3136c6808..8689fcef0 100644 --- a/source/core/lighting/radiosity.h +++ b/source/core/lighting/radiosity.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,24 +39,30 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +// Boost header files #if POV_MULTITHREADED #include #endif +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/path_fwd.h" + +// POV-Ray header files (core module) #include "core/lighting/photons.h" // TODO FIXME - make PhotonGatherer class visible only as a pointer #include "core/material/media.h" // TODO FIXME - make MediaFunction class visible only as a pointer #include "core/math/randcosweighted.h" #include "core/render/trace.h" // TODO FIXME - make Trace class visible only as a pointer -#include "core/support/octree.h" // TODO FIXME - this should only be included in radiosity.cpp +#include "core/support/octree_fwd.h" #include "core/support/statistics.h" -namespace pov_base -{ -class Path; -} - namespace pov { @@ -67,8 +73,6 @@ namespace pov /// /// @{ -class ViewData; - struct ot_block_struct; struct ot_node_struct; struct ot_id_struct; @@ -85,7 +89,7 @@ static const unsigned int RADIOSITY_MAX_SAMPLE_DIRECTIONS = kRandCosWeightedC // - it gives the highest possible number of "secondary strides", those being -274, 115, -44, -17, -7 and 3 // settings as effective for a particular bounce depth during a particular trace step -struct RadiosityRecursionSettings +struct RadiosityRecursionSettings final { // true "tweakables" unsigned int raysPerSample; // number of sample rays to shoot per sample @@ -104,7 +108,7 @@ struct RadiosityRecursionSettings // settings as specified in the scene file; // naming conventions are as per the respective scene file parameter -class SceneRadiositySettings +class SceneRadiositySettings final { public: @@ -168,12 +172,12 @@ class SceneRadiositySettings RadiosityRecursionSettings* GetRecursionSettings (bool final) const; }; -class RadiosityCache +class RadiosityCache final { public: - class BlockPool + class BlockPool final { friend class RadiosityCache; public: @@ -223,7 +227,7 @@ class RadiosityCache private: - struct Octree + struct Octree final { ot_node_struct *root; #if POV_MULTITHREADED @@ -234,7 +238,7 @@ class RadiosityCache Octree() : root(nullptr) {} }; - vector blockPools; // block pools ready to be re-used + std::vector blockPools; // block pools ready to be re-used #if POV_MULTITHREADED boost::mutex blockPoolsMutex; // lock this when accessing blockPools #endif @@ -254,16 +258,15 @@ class RadiosityCache static bool AverageNearBlock(ot_block_struct *block, void *void_info); }; -class RadiosityFunction : public Trace::RadiosityFunctor +class RadiosityFunction final : public Trace::RadiosityFunctor { public: - static const unsigned int TILE_MAX = OT_TILE_MAX; - static const unsigned int PRETRACE_INVALID = OT_PASS_INVALID; - static const unsigned int PRETRACE_FIRST = OT_PASS_FIRST; - static const unsigned int PRETRACE_MAX = OT_PASS_MAX; - static const unsigned int FINAL_TRACE = OT_PASS_FINAL; - static const unsigned int DEPTH_MAX = (OT_DEPTH_MAX < 20 ? OT_DEPTH_MAX : 20); + static const unsigned int PRETRACE_INVALID = kOctreePassInvalid; + static const unsigned int PRETRACE_FIRST = kOctreePassFirst; + static const unsigned int PRETRACE_MAX = kOctreePassMax; + static const unsigned int FINAL_TRACE = kOctreePassFinal; + static const unsigned int DEPTH_MAX = (kOctreeDepthMax < 20 ? kOctreeDepthMax : 20); static const unsigned int MAX_NEAREST_COUNT = 20; // initializes radiosity module from: @@ -274,9 +277,9 @@ class RadiosityFunction : public Trace::RadiosityFunctor // cf - the cooperate functor (whatever that is - some thing that handles inter-thread communication?) // ft - whether this is the final trace (i.e. not a radiosity pretrace step) // camera - position of the camera - RadiosityFunction(shared_ptr sd, TraceThreadData *td, + RadiosityFunction(std::shared_ptr sd, TraceThreadData *td, const SceneRadiositySettings& rs, RadiosityCache& rc, Trace::CooperateFunctor& cf, bool ft, const Vector3d& camera); - virtual ~RadiosityFunction(); + virtual ~RadiosityFunction() override; // looks up the ambient value for a certain point // ipoint - point on the surface @@ -285,10 +288,10 @@ class RadiosityFunction : public Trace::RadiosityFunctor // brilliance - brilliance // ambient_colour - (output) the ambient color at this point // weight - the base "weight" of the traced ray (used to compare against ADC bailout) - virtual void ComputeAmbient(const Vector3d& ipoint, const Vector3d& raw_normal, const Vector3d& layer_normal, DBL brilliance, MathColour& ambient_colour, DBL weight, TraceTicket& ticket); + virtual void ComputeAmbient(const Vector3d& ipoint, const Vector3d& raw_normal, const Vector3d& layer_normal, DBL brilliance, MathColour& ambient_colour, DBL weight, TraceTicket& ticket) override; // checks whether the specified recursion depth is still within the configured limits - virtual bool CheckRadiosityTraceLevel(const TraceTicket& ticket); + virtual bool CheckRadiosityTraceLevel(const TraceTicket& ticket) override; // retrieves top level statistics information to drive pretrace re-iteration virtual void GetTopLevelStats(long& queryCount, float& reuse); @@ -298,7 +301,7 @@ class RadiosityFunction : public Trace::RadiosityFunctor private: - class SampleDirectionGenerator + class SampleDirectionGenerator final { public: /// constructor @@ -329,7 +332,7 @@ class RadiosityFunction : public Trace::RadiosityFunctor }; // structure to store precomputed effective parameters for each recursion depth - struct RecursionParameters + struct RecursionParameters final { SampleDirectionGenerator directionGenerator; // sample generator for this recursion depth IntStatsIndex statsId; // statistics id for per-pass per-recursion statistics @@ -367,6 +370,7 @@ class RadiosityFunction : public Trace::RadiosityFunctor /// //############################################################################## -} // end of namespace +} +// end of namespace pov #endif // POVRAY_CORE_RADIOSITY_H diff --git a/source/core/lighting/subsurface.cpp b/source/core/lighting/subsurface.cpp index d3bd5078f..06ec56bfc 100644 --- a/source/core/lighting/subsurface.cpp +++ b/source/core/lighting/subsurface.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/lighting/subsurface.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/mathutil.h" +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -111,4 +119,5 @@ PreciseMathColour SubsurfaceInterior::GetReducedAlbedo(const MathColour& diffuse return result; } -} // end of namespace +} +// end of namespace pov diff --git a/source/core/lighting/subsurface.h b/source/core/lighting/subsurface.h index 559804411..95daa9a65 100644 --- a/source/core/lighting/subsurface.h +++ b/source/core/lighting/subsurface.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,9 +39,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// Boost header files #include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" namespace pov @@ -58,7 +67,8 @@ using boost::flyweights::flyweight; using boost::flyweights::key_value; /// Class storing SSLT data precomputed based on index of refraction. -class SubsurfaceInterior { +class SubsurfaceInterior final +{ public: @@ -70,13 +80,14 @@ class SubsurfaceInterior { static const int ReducedAlbedoSamples = 100; // precomputed reduced albedo for selected values of diffuse reflectance - struct PrecomputedReducedAlbedo { + struct PrecomputedReducedAlbedo final + { float reducedAlbedo[ReducedAlbedoSamples+1]; PrecomputedReducedAlbedo(float ior); PreciseColourChannel operator()(PreciseColourChannel diffuseReflectance) const; }; - flyweight > precomputedReducedAlbedo; + flyweight> precomputedReducedAlbedo; }; /// Approximation to the Fresnel diffuse reflectance. @@ -100,6 +111,7 @@ inline double FresnelDiffuseReflectance(double eta) /// //############################################################################## -} // end of namespace +} +// end of namespace pov #endif // POVRAY_CORE_SUBSURFACE_H diff --git a/source/core/material/blendmap.cpp b/source/core/material/blendmap.cpp index 62b265908..20a8bb4a4 100644 --- a/source/core/material/blendmap.cpp +++ b/source/core/material/blendmap.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/blendmap.h" -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) #include "core/material/normal.h" #include "core/material/pigment.h" #include "core/material/texture.h" @@ -159,9 +165,9 @@ TextureBlendMapPtr Create_Blend_Map (BlendMapTypeId type) ******************************************************************************/ template -shared_ptr Copy_Blend_Map (const shared_ptr& Old) +std::shared_ptr Copy_Blend_Map (const std::shared_ptr& Old) { - return shared_ptr(Old); + return std::shared_ptr(Old); } template ColourBlendMapPtr Copy_Blend_Map (const ColourBlendMapPtr& Old); @@ -221,3 +227,4 @@ template void BlendMap::Set(const Vector& data); template void BlendMap::Set(const Vector& data); } +// end of namespace pov diff --git a/source/core/material/blendmap.h b/source/core/material/blendmap.h index b4304fbb9..9b59a2b07 100644 --- a/source/core/material/blendmap.h +++ b/source/core/material/blendmap.h @@ -4,13 +4,11 @@ /// /// Declarations related to blend maps. /// -/// @note `frame.h` contains other colour stuff. -/// /// @copyright /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,6 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + namespace pov { @@ -64,7 +73,7 @@ enum BlendMapTypeId }; template -struct BlendMapEntry +struct BlendMapEntry final { SNGL value; DATA_T Vals; @@ -80,7 +89,7 @@ class BlendMap typedef BlendMapEntry Entry; typedef Entry* EntryPtr; typedef const Entry* EntryConstPtr; - typedef vector Vector; + typedef std::vector Vector; BlendMap(BlendMapTypeId type); virtual ~BlendMap() {} @@ -99,15 +108,16 @@ class BlendMap ******************************************************************************/ template -shared_ptr Create_Blend_Map (BlendMapTypeId type); +std::shared_ptr Create_Blend_Map (BlendMapTypeId type); template -shared_ptr Copy_Blend_Map (const shared_ptr& Old); +std::shared_ptr Copy_Blend_Map (const std::shared_ptr& Old); /// @} /// //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BLENDMAP_H diff --git a/source/core/material/interior.cpp b/source/core/material/interior.cpp index 7c74e0006..783d3c4e8 100644 --- a/source/core/material/interior.cpp +++ b/source/core/material/interior.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/interior.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/lighting/subsurface.h" #include "core/material/texture.h" @@ -60,7 +71,7 @@ Interior::Interior() hollow = false; - subsurface = shared_ptr(); + subsurface = std::shared_ptr(); } Interior::Interior(const Interior& source) @@ -74,7 +85,7 @@ Interior::Interior(const Interior& source) media = source.media; hollow = source.hollow; IOR = source.IOR; - subsurface = shared_ptr(source.subsurface); + subsurface = std::shared_ptr(source.subsurface); Caustics = source.Caustics; } @@ -84,13 +95,13 @@ Interior::~Interior() void Interior::Transform(const TRANSFORM *trans) { - for(vector::iterator i(media.begin());i != media.end(); i++) + for(std::vector::iterator i(media.begin());i != media.end(); i++) i->Transform(trans); } void Interior::PostProcess() { - for(vector::iterator i(media.begin());i != media.end(); i++) + for(std::vector::iterator i(media.begin());i != media.end(); i++) i->PostProcess(); } @@ -205,3 +216,4 @@ void Destroy_Material(MATERIAL *Material) } } +// end of namespace pov diff --git a/source/core/material/interior.h b/source/core/material/interior.h index 73634016e..88d7fcc44 100644 --- a/source/core/material/interior.h +++ b/source/core/material/interior.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" namespace pov @@ -77,5 +85,6 @@ void Destroy_Material(MATERIAL *); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_INTERIOR_H diff --git a/source/core/material/media.cpp b/source/core/material/media.cpp index 6137841c8..c8572f7ad 100644 --- a/source/core/material/media.cpp +++ b/source/core/material/media.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/media.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/lighting/lightsource.h" #include "core/lighting/photons.h" #include "core/material/pattern.h" @@ -52,6 +60,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + Media::Media() { Type = ISOTROPIC_SCATTERING; @@ -1205,3 +1217,4 @@ void MediaFunction::ComputeMediaScatteringAttenuation(MediaVector& medias, MathC } } +// end of namespace pov diff --git a/source/core/material/media.h b/source/core/material/media.h index 5e867c569..f33be6901 100644 --- a/source/core/material/media.h +++ b/source/core/material/media.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/render/trace.h" namespace pov @@ -62,16 +72,16 @@ enum SCATTERING_TYPES = 5 }; -void Transform_Density(vector& Density, const TRANSFORM *Trans); +void Transform_Density(std::vector& Density, const TRANSFORM *Trans); class MediaFunction : public Trace::MediaFunctor { public: MediaFunction(TraceThreadData *td, Trace *t, PhotonGatherer *pg); - virtual void ComputeMedia(vector& mediasource, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm); - virtual void ComputeMedia(const RayInteriorVector& mediasource, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm); - virtual void ComputeMedia(MediaVector& medias, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm); + virtual void ComputeMedia(std::vector& mediasource, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm) override; + virtual void ComputeMedia(const RayInteriorVector& mediasource, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm) override; + virtual void ComputeMedia(MediaVector& medias, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm) override; protected: /// pseudo-random number sequence RandomDoubleSequence randomNumbers; @@ -109,5 +119,6 @@ class MediaFunction : public Trace::MediaFunctor //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_MEDIA_H diff --git a/source/core/material/noise.cpp b/source/core/material/noise.cpp index 86e920e0d..3b67f01bc 100644 --- a/source/core/material/noise.cpp +++ b/source/core/material/noise.cpp @@ -17,7 +17,7 @@ /// ---------------------------------------------------------------------------- /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,12 +45,27 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/noise.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Static functions ******************************************************************************/ @@ -171,7 +186,7 @@ void Initialize_Noise() sintab[i] = sin((DBL)i / SINTABSIZE * TWO_M_PI); } -void Initialize_Waves(vector& waveFrequencies, vector& waveSources, unsigned int numberOfWaves) +void Initialize_Waves(std::vector& waveFrequencies, std::vector& waveSources, unsigned int numberOfWaves) { Vector3d point; @@ -709,3 +724,4 @@ const OptimizedNoiseInfo* GetOptimizedNoise(std::string name) #endif // TRY_OPTIMIZED_NOISE } +// end of namespace pov diff --git a/source/core/material/noise.h b/source/core/material/noise.h index 984559332..4a3f94e80 100644 --- a/source/core/material/noise.h +++ b/source/core/material/noise.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/warp.h" #include "core/math/vector.h" @@ -97,7 +108,7 @@ extern ALIGN16 DBL RTable[]; ******************************************************************************/ void Initialize_Noise (void); -void Initialize_Waves(vector& waveFrequencies, vector& waveSources, unsigned int numberOfWaves); +void Initialize_Waves(std::vector& waveFrequencies, std::vector& waveSources, unsigned int numberOfWaves); void Free_Noise_Tables (void); DBL SolidNoise(const Vector3d& P); @@ -111,7 +122,7 @@ typedef DBL(*NoiseFunction) (const Vector3d& EPoint, int noise_generator); typedef void(*DNoiseFunction) (Vector3d& result, const Vector3d& EPoint); /// Optimized noise dispatch information. -struct OptimizedNoiseInfo +struct OptimizedNoiseInfo final { /// String unambiguously identifying the optimized implementation. /// @@ -173,7 +184,7 @@ extern OptimizedNoiseInfo gaOptimizedNoiseInfo[]; const OptimizedNoiseInfo* GetRecommendedOptimizedNoise(); /// Get a specific noise generator implementation. -const OptimizedNoiseInfo* GetOptimizedNoise(std::string name); +const OptimizedNoiseInfo* GetOptimizedNoise(const std::string& name); extern NoiseFunction Noise; extern DNoiseFunction DNoise; @@ -195,5 +206,6 @@ void DTurbulence (Vector3d& result, const Vector3d& EPoint, const GenericTurbule //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_NOISE_H diff --git a/source/core/material/normal.cpp b/source/core/material/normal.cpp index a43afe35c..d39bad426 100644 --- a/source/core/material/normal.cpp +++ b/source/core/material/normal.cpp @@ -17,7 +17,7 @@ /// ---------------------------------------------------------------------------- /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,8 +45,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/normal.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/material/blendmap.h" #include "core/material/noise.h" #include "core/material/pigment.h" @@ -778,7 +785,7 @@ void Perturb_Normal(Vector3d& Layer_Normal, const TNORMAL *Tnormal, const Vector Vector3d TPoint,P1; DBL value1,Amount; int i; - shared_ptr Blend_Map; + std::shared_ptr Blend_Map; if (Tnormal == nullptr) { @@ -787,7 +794,7 @@ void Perturb_Normal(Vector3d& Layer_Normal, const TNORMAL *Tnormal, const Vector /* If normal_map present, use it and return */ - Blend_Map = dynamic_pointer_cast(Tnormal->Blend_Map); + Blend_Map = std::dynamic_pointer_cast(Tnormal->Blend_Map); if (Blend_Map != nullptr) { if (Tnormal->Type == UV_MAP_PATTERN) @@ -871,7 +878,7 @@ void Perturb_Normal(Vector3d& Layer_Normal, const TNORMAL *Tnormal, const Vector } else { - shared_ptr slopeMap = dynamic_pointer_cast(Tnormal->Blend_Map); + std::shared_ptr slopeMap = std::dynamic_pointer_cast(Tnormal->Blend_Map); Warp_Normal(Layer_Normal,Layer_Normal, Tnormal, Test_Flag(Tnormal,DONT_SCALE_BUMPS_FLAG)); @@ -1048,5 +1055,5 @@ void NormalBlendMap::ComputeAverage (const Vector3d& EPoint, Vector3d& normal, I normal = V1 / Total; } - } +// end of namespace pov diff --git a/source/core/material/normal.h b/source/core/material/normal.h index 016a9aa8b..bd46d81a6 100644 --- a/source/core/material/normal.h +++ b/source/core/material/normal.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,9 +39,20 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/material/blendmap.h" #include "core/math/vector.h" +#include "core/render/ray_fwd.h" namespace pov { @@ -53,10 +64,6 @@ namespace pov /// /// @{ -class Intersection; -class Ray; -class TraceThreadData; - /// Common interface for normal-like blend maps. /// /// This purely abstract class provides the common interface for both normal and slope blend maps. @@ -73,42 +80,42 @@ class GenericNormalBlendMap virtual void ComputeAverage (const Vector3d& EPoint, Vector3d& normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread) = 0; }; -class SlopeBlendMap : public BlendMap, public GenericNormalBlendMap +class SlopeBlendMap final : public BlendMap, public GenericNormalBlendMap { public: SlopeBlendMap(); - virtual ~SlopeBlendMap(); + virtual ~SlopeBlendMap() override; - virtual void Post(bool dontScaleBumps); - virtual void ComputeAverage (const Vector3d& EPoint, Vector3d& normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread); + virtual void Post(bool dontScaleBumps) override; + virtual void ComputeAverage (const Vector3d& EPoint, Vector3d& normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread) override; }; -class NormalBlendMap : public BlendMap, public GenericNormalBlendMap +class NormalBlendMap final : public BlendMap, public GenericNormalBlendMap { public: NormalBlendMap(); - virtual ~NormalBlendMap(); + virtual ~NormalBlendMap() override; - virtual void Post(bool dontScaleBumps); - virtual void ComputeAverage (const Vector3d& EPoint, Vector3d& normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread); + virtual void Post(bool dontScaleBumps) override; + virtual void ComputeAverage (const Vector3d& EPoint, Vector3d& normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread) override; }; -typedef shared_ptr GenericNormalBlendMapPtr; -typedef shared_ptr GenericNormalBlendMapConstPtr; +typedef std::shared_ptr GenericNormalBlendMapPtr; +typedef std::shared_ptr GenericNormalBlendMapConstPtr; -typedef Vector2d SlopeBlendMapData; -typedef BlendMapEntry SlopeBlendMapEntry; -typedef shared_ptr SlopeBlendMapPtr; -typedef shared_ptr SlopeBlendMapConstPtr; +typedef Vector2d SlopeBlendMapData; +typedef BlendMapEntry SlopeBlendMapEntry; +typedef std::shared_ptr SlopeBlendMapPtr; +typedef std::shared_ptr SlopeBlendMapConstPtr; -typedef TNORMAL* NormalBlendMapData; -typedef BlendMapEntry NormalBlendMapEntry; -typedef shared_ptr NormalBlendMapPtr; -typedef shared_ptr NormalBlendMapConstPtr; +typedef TNORMAL* NormalBlendMapData; +typedef BlendMapEntry NormalBlendMapEntry; +typedef std::shared_ptr NormalBlendMapPtr; +typedef std::shared_ptr NormalBlendMapConstPtr; -struct Tnormal_Struct : public Pattern_Struct +struct Tnormal_Struct final : public Pattern_Struct { GenericNormalBlendMapPtr Blend_Map; SNGL Amount; @@ -127,5 +134,6 @@ void Perturb_Normal (Vector3d& Layer_Normal, const TNORMAL *Tnormal, const Vecto //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_NORMAL_H diff --git a/source/core/material/pattern.cpp b/source/core/material/pattern.cpp index 9dec6f4fd..fb55df1a1 100644 --- a/source/core/material/pattern.cpp +++ b/source/core/material/pattern.cpp @@ -14,7 +14,7 @@ /// ---------------------------------------------------------------------------- /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -42,11 +42,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/pattern.h" -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include +#include +// POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/material/blendmap.h" #include "core/material/noise.h" #include "core/material/pigment.h" @@ -65,6 +73,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -1068,8 +1079,8 @@ void BlendMap::Search (DBL value, EntryConstPtr& rpPrev, EntryConstPtr& { // TODO - we might use a binary search instead - typename vector::const_iterator iP; - typename vector::const_iterator iN; + typename std::vector::const_iterator iP; + typename std::vector::const_iterator iN; iP = iN = Blend_Map_Entries.begin(); @@ -9378,3 +9389,4 @@ void InitializePatternGenerators(void) } } +// end of namespace pov diff --git a/source/core/material/pattern.h b/source/core/material/pattern.h index b4286f9b7..95159fd93 100644 --- a/source/core/material/pattern.h +++ b/source/core/material/pattern.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,12 +38,20 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/material/pattern_fwd.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// Boost header files #include // required for crackle #include -#include "base/fileinputoutput.h" +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/material/pigment.h" #include "core/material/warp.h" @@ -309,7 +317,7 @@ struct ContinuousPattern : public BasicPattern /// crackle pattern, store cached data here. /// @return The pattern's value at the given point in space. /// - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override final; /// Evaluates the pattern at a given point in space, without taking into account the wave function. /// @@ -325,34 +333,34 @@ struct ContinuousPattern : public BasicPattern /// virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const = 0; - virtual unsigned int NumDiscreteBlendMapEntries() const; - virtual bool CanMap() const; + virtual unsigned int NumDiscreteBlendMapEntries() const override; + virtual bool CanMap() const override; }; /// Abstract class providing additions to the basic pattern interface, as well as common code, for all /// discrete pattern implementations. struct DiscretePattern : public BasicPattern { - virtual bool CanMap() const; + virtual bool CanMap() const override; }; /// Implements a plain pattern with all-zero values for any point in space. -struct PlainPattern : public DiscretePattern +struct PlainPattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual unsigned int NumDiscreteBlendMapEntries() const; - virtual bool HasSpecialTurbulenceHandling() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; + virtual bool HasSpecialTurbulenceHandling() const override; }; /// Implements a dummy pattern for `average` pseudo-pattern. -struct AveragePattern : public BasicPattern +struct AveragePattern final : public BasicPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual unsigned int NumDiscreteBlendMapEntries() const; - virtual bool HasSpecialTurbulenceHandling() const; - virtual bool CanMap() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; + virtual bool HasSpecialTurbulenceHandling() const override; + virtual bool CanMap() const override; }; /// Class providing additional data members for image-based patterns. @@ -373,34 +381,34 @@ struct ImagePatternImpl // Miscellaneous Patterns /// Implements the `agate` pattern. -struct AgatePattern : public ContinuousPattern +struct AgatePattern final : public ContinuousPattern { /// `agate_turb` parameter. SNGL agateTurbScale; AgatePattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual bool Precompute(); - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual bool Precompute() override; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; }; /// Implements the `aoi` pattern. -struct AOIPattern : public ContinuousPattern +struct AOIPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `boxed` pattern. -struct BoxedPattern : public ContinuousPattern +struct BoxedPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `brick` pattern. -struct BrickPattern : public DiscretePattern +struct BrickPattern final : public DiscretePattern { /// `brick_size` parameter. Vector3d brickSize; @@ -409,30 +417,30 @@ struct BrickPattern : public DiscretePattern SNGL mortar; BrickPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `cells` pattern. -struct CellsPattern : public ContinuousPattern +struct CellsPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `checker` pattern. -struct CheckerPattern : public DiscretePattern +struct CheckerPattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `crackle` pattern. -struct CracklePattern : public ContinuousPattern +struct CracklePattern final : public ContinuousPattern { Vector3d crackleForm; DBL crackleMetric; @@ -441,34 +449,34 @@ struct CracklePattern : public ContinuousPattern bool crackleIsSolid; CracklePattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `cubic` pattern. -struct CubicPattern : public DiscretePattern +struct CubicPattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `cylindrical` pattern. -struct CylindricalPattern : public ContinuousPattern +struct CylindricalPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `density_file` pattern. /// /// @todo The additional member variables should be encapsulated. /// -struct DensityFilePattern : public ContinuousPattern +struct DensityFilePattern final : public ContinuousPattern { /// @todo fix the members to match naming conventions - struct DensityFileDataStruct + struct DensityFileDataStruct final { int References; char *Name; @@ -482,7 +490,7 @@ struct DensityFilePattern : public ContinuousPattern }; }; /// @todo fix the members to match naming conventions - struct DensityFileStruct + struct DensityFileStruct final { int Interpolation; ///< one of @ref DensityFileInterpolationType DensityFileDataStruct *Data; @@ -492,98 +500,98 @@ struct DensityFilePattern : public ContinuousPattern DensityFilePattern(); DensityFilePattern(const DensityFilePattern& obj); - virtual ~DensityFilePattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual ~DensityFilePattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; -typedef struct DensityFilePattern::DensityFileStruct DENSITY_FILE; ///< @deprecated @ref DensityFilePattern::DensityFileStruct should be used instead. -typedef struct DensityFilePattern::DensityFileDataStruct DENSITY_FILE_DATA; ///< @deprecated @ref DensityFilePattern::DensityFileDataStruct should be used instead. +using DENSITY_FILE = DensityFilePattern::DensityFileStruct; ///< @deprecated @ref DensityFilePattern::DensityFileStruct should be used instead. +using DENSITY_FILE_DATA = DensityFilePattern::DensityFileDataStruct ; ///< @deprecated @ref DensityFilePattern::DensityFileDataStruct should be used instead. /// Implements the `dents` pattern. -struct DentsPattern : public ContinuousPattern +struct DentsPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `facets` pattern. -struct FacetsPattern : public ContinuousPattern +struct FacetsPattern final : public ContinuousPattern { DBL facetsSize, facetsCoords, facetsMetric; FacetsPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } /// @attention As the `facets` pattern is only available for normals, this function is not supposed to be ever /// called, and will throw an exception. /// - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `function` pattern. /// /// @todo The additional member variables should be encapsulated. /// -struct FunctionPattern : public ContinuousPattern +struct FunctionPattern final : public ContinuousPattern { GenericScalarFunctionPtr pFn; FunctionPattern(); FunctionPattern(const FunctionPattern& obj); - virtual ~FunctionPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual ~FunctionPattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `gradient` pattern. -struct GradientPattern : public ContinuousPattern +struct GradientPattern final : public ContinuousPattern { /// Direction of the gradient. Vector3d gradient; - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `granite` pattern. -struct GranitePattern : public ContinuousPattern +struct GranitePattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `hexagon` pattern. -struct HexagonPattern : public DiscretePattern +struct HexagonPattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements image-based mapped patterns. -struct ImagePattern : public ContinuousPattern, public ImagePatternImpl +struct ImagePattern final : public ContinuousPattern, public ImagePatternImpl { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `leopard` pattern. -struct LeopardPattern : public ContinuousPattern +struct LeopardPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `marble` pattern. -struct MarblePattern : public ContinuousPattern +struct MarblePattern final : public ContinuousPattern { MarblePattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual bool Precompute(); - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual bool HasSpecialTurbulenceHandling() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual bool Precompute() override; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual bool HasSpecialTurbulenceHandling() const override; protected: @@ -593,32 +601,32 @@ struct MarblePattern : public ContinuousPattern /// Base class for the noise-based patterns. struct NoisePattern : public ContinuousPattern { - virtual PatternPtr Clone() const = 0; - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override = 0; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `object` pattern. /// /// @todo The additional member variables should possibly be encapsulated. /// -struct ObjectPattern : public DiscretePattern +struct ObjectPattern final : public DiscretePattern { ObjectPtr pObject; ObjectPattern(); ObjectPattern(const ObjectPattern& obj); - virtual ~ObjectPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual ~ObjectPattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `onion` pattern. -struct OnionPattern : public ContinuousPattern +struct OnionPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `pavement` pattern. @@ -626,7 +634,7 @@ struct OnionPattern : public ContinuousPattern /// @todo We should probably implement this as one class per pavement type, possibly all declared in @ref pattern.cpp /// and instantiated via a static factory method in this class. /// -struct PavementPattern : public ContinuousPattern +struct PavementPattern final : public ContinuousPattern { unsigned char Side; unsigned char Tile; @@ -636,8 +644,8 @@ struct PavementPattern : public ContinuousPattern unsigned char Form; PavementPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; DBL hexagonal (const Vector3d& EPoint) const; DBL trigonal (const Vector3d& EPoint) const; DBL tetragonal (const Vector3d& EPoint) const; @@ -647,70 +655,70 @@ struct PavementPattern : public ContinuousPattern /// /// @todo The additional member variables should possibly be encapsulated. /// -struct PigmentPattern : public ContinuousPattern +struct PigmentPattern final : public ContinuousPattern { PIGMENT *pPigment; PigmentPattern(); PigmentPattern(const PigmentPattern& obj); - virtual ~PigmentPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual ~PigmentPattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `planar` pattern. -struct PlanarPattern : public ContinuousPattern +struct PlanarPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `potential` pattern. /// /// @todo The additional member variables should possibly be encapsulated. /// -struct PotentialPattern : public ContinuousPattern +struct PotentialPattern final : public ContinuousPattern { ObjectPtr pObject; bool subtractThreshold; PotentialPattern(); PotentialPattern(const PotentialPattern& obj); - virtual ~PotentialPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual ~PotentialPattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `quilted` pattern. -struct QuiltedPattern : public ContinuousPattern +struct QuiltedPattern final : public ContinuousPattern { SNGL Control0, Control1; QuiltedPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `radial` pattern. -struct RadialPattern : public ContinuousPattern +struct RadialPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; }; /// Implements the `ripples` pattern. -struct RipplesPattern : public ContinuousPattern +struct RipplesPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `slope` pattern. /// /// @todo The additional member variables should be encapsulated, and computed by the class rather than the parser. /// -struct SlopePattern : public ContinuousPattern +struct SlopePattern final : public ContinuousPattern { Vector3d altitudeDirection; Vector3d slopeDirection; @@ -725,24 +733,24 @@ struct SlopePattern : public ContinuousPattern bool pointAt : 1; SlopePattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `spherical` pattern. -struct SphericalPattern : public ContinuousPattern +struct SphericalPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `square` pattern. -struct SquarePattern : public DiscretePattern +struct SquarePattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `tiling` pattern. @@ -750,39 +758,39 @@ struct SquarePattern : public DiscretePattern /// @todo We should probably implement this as one class per tiling type, possibly all declared in @ref pattern.cpp /// and instantiated via a static factory method in this class. /// -struct TilingPattern : public ContinuousPattern +struct TilingPattern final : public ContinuousPattern { unsigned char tilingType; - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `triangular` pattern. -struct TriangularPattern : public DiscretePattern +struct TriangularPattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `waves` pattern. -struct WavesPattern : public ContinuousPattern +struct WavesPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `wood` pattern. -struct WoodPattern : public ContinuousPattern +struct WoodPattern final : public ContinuousPattern { WoodPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual bool Precompute(); - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual bool HasSpecialTurbulenceHandling() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual bool Precompute() override; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual bool HasSpecialTurbulenceHandling() const override; protected: @@ -790,10 +798,10 @@ struct WoodPattern : public ContinuousPattern }; /// Implements the `wrinkles` pattern. -struct WrinklesPattern : public ContinuousPattern +struct WrinklesPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; @@ -819,8 +827,8 @@ struct FractalPattern : public ContinuousPattern unsigned char interiorType; FractalPattern(); - virtual PatternPtr Clone() const = 0; - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const = 0; + virtual PatternPtr Clone() const override = 0; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override = 0; protected: @@ -837,7 +845,7 @@ struct FractalPattern : public ContinuousPattern /// /// @param a Final iteration "a" value. /// @param b Final iteration "b" value. - /// @param mindist2 Square of the smallest distance to the origin thoughout all iterations. + /// @param mindist2 Square of the smallest distance to the origin throughout all iterations. /// @return The interior shade. /// DBL InteriorColour(DBL a, DBL b, DBL mindist2) const; @@ -857,38 +865,38 @@ struct JuliaPattern : public FractalPattern JuliaPattern(); JuliaPattern(const JuliaPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Provides an implementation of the `julia` pattern optimized for `exponent 3`. -struct Julia3Pattern : public JuliaPattern +struct Julia3Pattern final : public JuliaPattern { Julia3Pattern(); Julia3Pattern(const JuliaPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Provides an implementation of the `julia` pattern optimized for `exponent 4`. -struct Julia4Pattern : public JuliaPattern +struct Julia4Pattern final : public JuliaPattern { Julia4Pattern(); Julia4Pattern(const JuliaPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Provides a generic implementation of the `julia` pattern for arbitrary exponents. -struct JuliaXPattern : public JuliaPattern +struct JuliaXPattern final : public JuliaPattern { int fractalExponent; JuliaXPattern(); JuliaXPattern(const JuliaPattern& obj); JuliaXPattern(const JuliaXPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; //------------------------------------------------------------------------------ @@ -900,74 +908,74 @@ struct MandelPattern : public FractalPattern }; /// Provides an implementation of the `mandel` pattern optimized for `exponent 2` (default). -struct Mandel2Pattern : public MandelPattern +struct Mandel2Pattern final : public MandelPattern { Mandel2Pattern(); Mandel2Pattern(const MandelPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; }; /// Provides an implementation of the `mandel` pattern optimized for `exponent 3`. -struct Mandel3Pattern : public MandelPattern +struct Mandel3Pattern final : public MandelPattern { Mandel3Pattern(); Mandel3Pattern(const MandelPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Provides an implementation of the `mandel` pattern optimized for `exponent 4`. -struct Mandel4Pattern : public MandelPattern +struct Mandel4Pattern final : public MandelPattern { Mandel4Pattern(); Mandel4Pattern(const MandelPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Provides a generic implementation of the `mandel` pattern for arbitrary exponents. -struct MandelXPattern : public MandelPattern +struct MandelXPattern final : public MandelPattern { int fractalExponent; MandelXPattern(); MandelXPattern(const MandelPattern& obj); MandelXPattern(const MandelXPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; //------------------------------------------------------------------------------ // Magnet Patterns /// Implements the `magnet 1 mandel` pattern. -struct Magnet1MPattern : public MandelPattern +struct Magnet1MPattern final : public MandelPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `magnet 1 julia` pattern. -struct Magnet1JPattern : public JuliaPattern +struct Magnet1JPattern final : public JuliaPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `magnet 2 mandel` pattern. -struct Magnet2MPattern : public MandelPattern +struct Magnet2MPattern final : public MandelPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `magnet 2 julia` pattern. -struct Magnet2JPattern : public JuliaPattern +struct Magnet2JPattern final : public JuliaPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; @@ -975,22 +983,22 @@ struct Magnet2JPattern : public JuliaPattern // Noise-Based Patterns /// Implements the `bozo` pattern. -struct BozoPattern : public NoisePattern +struct BozoPattern final : public NoisePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; }; /// Implements the `bumps` pattern. -struct BumpsPattern : public NoisePattern +struct BumpsPattern final : public NoisePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } }; /// Implements the `spotted` pattern. -struct SpottedPattern : public NoisePattern +struct SpottedPattern final : public NoisePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } }; @@ -1003,9 +1011,9 @@ struct SpiralPattern : public ContinuousPattern short arms; SpiralPattern(); - virtual PatternPtr Clone() const = 0; - virtual bool Precompute(); - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const = 0; + virtual PatternPtr Clone() const override = 0; + virtual bool Precompute() override; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override = 0; protected: @@ -1013,17 +1021,17 @@ struct SpiralPattern : public ContinuousPattern }; /// Implements the `spiral1` pattern. -struct Spiral1Pattern : public SpiralPattern +struct Spiral1Pattern final : public SpiralPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `spiral2` pattern. -struct Spiral2Pattern : public SpiralPattern +struct Spiral2Pattern final : public SpiralPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; @@ -1051,10 +1059,10 @@ struct ColourPattern : public BasicPattern /// crackle pattern, store cached data here. /// @return The pattern's value at the given point in space. /// - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override final; - virtual unsigned int NumDiscreteBlendMapEntries() const; - virtual bool CanMap() const; + virtual unsigned int NumDiscreteBlendMapEntries() const override; + virtual bool CanMap() const override; /// Evaluates the pattern at a given point in space. /// @@ -1079,24 +1087,24 @@ struct ColourPattern : public BasicPattern /// /// @todo The additional member variables should possibly be encapsulated. /// -struct ColourFunctionPattern : public ColourPattern +struct ColourFunctionPattern final : public ColourPattern { GenericScalarFunctionPtr pFn[5]; ColourFunctionPattern(); ColourFunctionPattern(const ColourFunctionPattern& obj); - virtual ~ColourFunctionPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual bool Evaluate(TransColour& result, const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual bool HasTransparency() const; + virtual ~ColourFunctionPattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual bool Evaluate(TransColour& result, const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual bool HasTransparency() const override; }; /// Implements the `image_map` pattern. -struct ColourImagePattern : public ColourPattern, public ImagePatternImpl +struct ColourImagePattern final : public ColourPattern, public ImagePatternImpl { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual bool Evaluate(TransColour& result, const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual bool HasTransparency() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual bool Evaluate(TransColour& result, const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual bool HasTransparency() const override; }; @@ -1104,7 +1112,7 @@ struct ColourImagePattern : public ColourPattern, public ImagePatternImpl // Crackle Pattern Support Types /// Helper class to implement the crackle cache. -class CrackleCellCoord +class CrackleCellCoord final { public: @@ -1159,7 +1167,7 @@ class CrackleCellCoord }; /// Helper class to implement the crackle cache. -struct CrackleCacheEntry +struct CrackleCacheEntry final { /// A kind of timestamp specifying when this particular entry was last used. size_t lastUsed; @@ -1168,7 +1176,7 @@ struct CrackleCacheEntry Vector3d aCellNuclei[81]; }; -typedef boost::unordered_map > CrackleCache; +typedef boost::unordered_map> CrackleCache; //****************************************************************************** @@ -1197,5 +1205,6 @@ void InitializePatternGenerators(void); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PATTERN_H diff --git a/source/core/material/pattern_fwd.h b/source/core/material/pattern_fwd.h new file mode 100644 index 000000000..17c99923e --- /dev/null +++ b/source/core/material/pattern_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file core/material/pattern_fwd.h +/// +/// Forward declarations related to patterns. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_CORE_PATTERN_FWD_H +#define POVRAY_CORE_PATTERN_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +struct ImagePattern; + +} +// end of namespace pov + +#endif // POVRAY_CORE_PATTERN_FWD_H diff --git a/source/core/material/pigment.cpp b/source/core/material/pigment.cpp index cf59fe5e4..7d658573a 100644 --- a/source/core/material/pigment.cpp +++ b/source/core/material/pigment.cpp @@ -14,7 +14,7 @@ /// ---------------------------------------------------------------------------- /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -42,8 +42,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/pigment.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/povassert.h" +#include "base/image/colourspace.h" +// POV-Ray header files (core module) #include "core/material/blendmap.h" #include "core/material/pattern.h" #include "core/material/warp.h" @@ -57,6 +65,8 @@ namespace pov { +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -157,7 +167,7 @@ PIGMENT *Copy_Pigment (PIGMENT *Old) New = Create_Pigment (); Copy_TPat_Fields (New, Old); - New->Blend_Map = shared_ptr (Old->Blend_Map); + New->Blend_Map = std::shared_ptr (Old->Blend_Map); New->colour = Old->colour; New->Quick_Colour = Old->Quick_Colour; @@ -284,8 +294,8 @@ void Post_Pigment(PIGMENT *Pigment, bool* pHasFilter) break; default: - Pigment->Blend_Map = static_pointer_cast( - const_pointer_cast( + Pigment->Blend_Map = std::static_pointer_cast( + std::const_pointer_cast( Pigment->pattern->GetDefaultBlendMap())); break; } @@ -435,8 +445,8 @@ bool Compute_Pigment (TransColour& colour, const PIGMENT *Pigment, const Vector3 colour.Clear(); - POV_PATTERN_ASSERT(dynamic_pointer_cast(Pigment->pattern)); - Colour_Found = static_pointer_cast(Pigment->pattern)->Evaluate(colour, TPoint, Intersect, ray, Thread); + POV_PATTERN_ASSERT(std::dynamic_pointer_cast(Pigment->pattern)); + Colour_Found = std::dynamic_pointer_cast(Pigment->pattern)->Evaluate(colour, TPoint, Intersect, ray, Thread); break; @@ -671,4 +681,4 @@ PigmentBlendMap::~PigmentBlendMap() } } - +// end of namespace pov diff --git a/source/core/material/pigment.h b/source/core/material/pigment.h index fd5232148..8329ca2cc 100644 --- a/source/core/material/pigment.h +++ b/source/core/material/pigment.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,10 +39,20 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "base/image/colourspace.h" +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +#include "base/image/colourspace_fwd.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/material/blendmap.h" +#include "core/render/ray_fwd.h" namespace pov { @@ -54,10 +64,6 @@ namespace pov /// /// @{ -class Intersection; -class Ray; -class TraceThreadData; - /// Common interface for pigment-like blend maps. /// /// This class provides the common interface for both pigment and colour blend maps. @@ -81,49 +87,49 @@ class GenericPigmentBlendMap }; /// Colour blend map. -class ColourBlendMap : public BlendMap, public GenericPigmentBlendMap +class ColourBlendMap final : public BlendMap, public GenericPigmentBlendMap { public: ColourBlendMap(); ColourBlendMap(int n, const Entry aEntries[]); - virtual bool Compute(TransColour& colour, DBL value, const Vector3d& IPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual void ComputeAverage(TransColour& colour, const Vector3d& EPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual bool ComputeUVMapped(TransColour& colour, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual void Post(bool& rHasFilter); + virtual bool Compute(TransColour& colour, DBL value, const Vector3d& IPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual void ComputeAverage(TransColour& colour, const Vector3d& EPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual bool ComputeUVMapped(TransColour& colour, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual void Post(bool& rHasFilter) override; }; /// Pigment blend map. -class PigmentBlendMap : public BlendMap, public GenericPigmentBlendMap +class PigmentBlendMap final : public BlendMap, public GenericPigmentBlendMap { public: PigmentBlendMap(BlendMapTypeId type); - virtual ~PigmentBlendMap(); + virtual ~PigmentBlendMap() override; - virtual bool Compute(TransColour& colour, DBL value, const Vector3d& IPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual void ComputeAverage(TransColour& colour, const Vector3d& EPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual bool ComputeUVMapped(TransColour& colour, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual void Post(bool& rHasFilter); + virtual bool Compute(TransColour& colour, DBL value, const Vector3d& IPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual void ComputeAverage(TransColour& colour, const Vector3d& EPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual bool ComputeUVMapped(TransColour& colour, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual void Post(bool& rHasFilter) override; }; -typedef shared_ptr GenericPigmentBlendMapPtr; -typedef shared_ptr GenericPigmentBlendMapConstPtr; +typedef std::shared_ptr GenericPigmentBlendMapPtr; +typedef std::shared_ptr GenericPigmentBlendMapConstPtr; -typedef PIGMENT* PigmentBlendMapData; -typedef BlendMapEntry PigmentBlendMapEntry; -typedef shared_ptr PigmentBlendMapPtr; -typedef shared_ptr PigmentBlendMapConstPtr; +typedef PIGMENT* PigmentBlendMapData; +typedef BlendMapEntry PigmentBlendMapEntry; +typedef std::shared_ptr PigmentBlendMapPtr; +typedef std::shared_ptr PigmentBlendMapConstPtr; -typedef TransColour ColourBlendMapData; -typedef BlendMapEntry ColourBlendMapEntry; -typedef shared_ptr ColourBlendMapPtr; -typedef shared_ptr ColourBlendMapConstPtr; +typedef TransColour ColourBlendMapData; +typedef BlendMapEntry ColourBlendMapEntry; +typedef std::shared_ptr ColourBlendMapPtr; +typedef std::shared_ptr ColourBlendMapConstPtr; -struct Pigment_Struct : public Pattern_Struct +struct Pigment_Struct final : public Pattern_Struct { - shared_ptr Blend_Map; + std::shared_ptr Blend_Map; TransColour colour; // may have a filter/transmit component TransColour Quick_Colour; // may have a filter/transmit component // TODO - can't we decide between regular colour and quick_colour at parse time already? }; @@ -131,16 +137,17 @@ struct Pigment_Struct : public Pattern_Struct PIGMENT *Create_Pigment(); PIGMENT *Copy_Pigment(PIGMENT *Old); -void Copy_Pigments (vector& New, const vector& Old); +void Copy_Pigments (std::vector& New, const std::vector& Old); void Destroy_Pigment(PIGMENT *Pigment); void Post_Pigment(PIGMENT *Pigment, bool* pHasFilter = nullptr); bool Compute_Pigment(TransColour& colour, const PIGMENT *Pigment, const Vector3d& IPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); -void Evaluate_Density_Pigment(vector& Density, const Vector3d& p, MathColour& c, TraceThreadData *ttd); +void Evaluate_Density_Pigment(std::vector& Density, const Vector3d& p, MathColour& c, TraceThreadData *ttd); /// @} /// //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PIGMENT_H diff --git a/source/core/material/portablenoise.cpp b/source/core/material/portablenoise.cpp index a4e039620..8e994503f 100644 --- a/source/core/material/portablenoise.cpp +++ b/source/core/material/portablenoise.cpp @@ -16,7 +16,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -46,6 +46,14 @@ #include "core/material/portablenoise.h" #endif // PORTABLE_OPTIMIZED_NOISE +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/noise.h" namespace pov @@ -370,3 +378,4 @@ void PortableDNoise(Vector3d& result, const Vector3d& EPoint) } } +// end of namespace pov diff --git a/source/core/material/portablenoise.h b/source/core/material/portablenoise.h index 9a1314dbc..c52193590 100644 --- a/source/core/material/portablenoise.h +++ b/source/core/material/portablenoise.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,4 +39,12 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + #endif // POVRAY_CORE_PORTABLENOISE_H diff --git a/source/core/material/texture.cpp b/source/core/material/texture.cpp index 6c259873d..561054693 100644 --- a/source/core/material/texture.cpp +++ b/source/core/material/texture.cpp @@ -19,7 +19,7 @@ /// ---------------------------------------------------------------------------- /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -47,10 +47,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/texture.h" -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/material/pattern.h" #include "core/material/pigment.h" #include "core/material/normal.h" @@ -62,6 +67,8 @@ namespace pov { +using std::vector; + /***************************************************************************** * * FUNCTION @@ -711,3 +718,4 @@ TextureBlendMap::~TextureBlendMap() } } +// end of namespace pov diff --git a/source/core/material/texture.h b/source/core/material/texture.h index 3cbef8fa4..98ce7cbb4 100644 --- a/source/core/material/texture.h +++ b/source/core/material/texture.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/material/blendmap.h" #include "core/support/simplevector.h" @@ -53,7 +64,6 @@ namespace pov /// /// @{ -typedef struct Turb_Struct TURB; struct GenericTurbulenceWarp; /***************************************************************************** @@ -70,7 +80,7 @@ struct GenericTurbulenceWarp; * Global typedefs ******************************************************************************/ -struct WeightedTexture +struct WeightedTexture final { COLC weight; TEXTURE *texture; @@ -83,19 +93,19 @@ typedef PooledSimpleVector Weighte /// Texture blend map. -class TextureBlendMap : public BlendMap +class TextureBlendMap final : public BlendMap { public: TextureBlendMap(); - ~TextureBlendMap(); + virtual ~TextureBlendMap() override; }; typedef BlendMapEntry TextureBlendMapEntry; -typedef shared_ptr TextureBlendMapPtr; -typedef shared_ptr TextureBlendMapConstPtr; +typedef std::shared_ptr TextureBlendMapPtr; +typedef std::shared_ptr TextureBlendMapConstPtr; -struct Texture_Struct : public Pattern_Struct +struct Texture_Struct final : public Pattern_Struct { TextureBlendMapPtr Blend_Map; int References; @@ -103,10 +113,10 @@ struct Texture_Struct : public Pattern_Struct PIGMENT *Pigment; TNORMAL *Tnormal; FINISH *Finish; - vector Materials; // used for `material_map` (and only there) + std::vector Materials; // used for `material_map` (and only there) }; -struct Finish_Struct +struct Finish_Struct final { SNGL Diffuse, DiffuseBack, Brilliance; #if POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT @@ -152,5 +162,6 @@ int Test_Opacity (const TEXTURE *Texture); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TEXTURE_H diff --git a/source/core/material/warp.cpp b/source/core/material/warp.cpp index 7e7ea07b1..aac5724aa 100644 --- a/source/core/material/warp.cpp +++ b/source/core/material/warp.cpp @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/warp.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/material/noise.h" #include "core/material/pattern.h" #include "core/material/texture.h" @@ -687,3 +693,4 @@ void Copy_Warps (WarpList& rNew, const WarpList& old) } } +// end of namespace pov diff --git a/source/core/material/warp.h b/source/core/material/warp.h index 086752e4a..f3ef5561d 100644 --- a/source/core/material/warp.h +++ b/source/core/material/warp.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/math/vector.h" @@ -67,10 +77,10 @@ struct GenericWarp typedef GenericWarp* WarpPtr; typedef const GenericWarp* ConstWarpPtr; -typedef vector WarpList; +typedef std::vector WarpList; -struct BlackHoleWarp : public GenericWarp +struct BlackHoleWarp final : public GenericWarp { BlackHoleWarp() : GenericWarp(), Center(0.0), Repeat_Vector(0.0), Uncertainty_Vector(0.0), Strength(1.0), Radius(1.0), @@ -83,10 +93,10 @@ struct BlackHoleWarp : public GenericWarp Inverted(old.Inverted), Repeat(old.Repeat), Uncertain(old.Uncertain) {} - virtual GenericWarp* Clone() const { return new BlackHoleWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new BlackHoleWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Center; Vector3d Repeat_Vector; @@ -102,18 +112,18 @@ struct BlackHoleWarp : public GenericWarp bool Uncertain; }; -struct CubicWarp : public GenericWarp +struct CubicWarp final : public GenericWarp { CubicWarp() : GenericWarp() {} CubicWarp(const CubicWarp& old) : GenericWarp(old) {} - virtual GenericWarp* Clone() const { return new CubicWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new CubicWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; }; -struct CylindricalWarp : public GenericWarp +struct CylindricalWarp final : public GenericWarp { CylindricalWarp() : GenericWarp(), Orientation_Vector(0.0, 0.0, 1.0), DistExp(0.0) @@ -122,27 +132,27 @@ struct CylindricalWarp : public GenericWarp GenericWarp(old), Orientation_Vector(old.Orientation_Vector), DistExp(old.DistExp) {} - virtual GenericWarp* Clone() const { return new CylindricalWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new CylindricalWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Orientation_Vector; DBL DistExp; }; -struct IdentityWarp : public GenericWarp +struct IdentityWarp final : public GenericWarp { IdentityWarp() : GenericWarp() {} IdentityWarp(const IdentityWarp& old) : GenericWarp(old) {} - virtual GenericWarp* Clone() const { return new IdentityWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new IdentityWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; }; -struct PlanarWarp : public GenericWarp +struct PlanarWarp final : public GenericWarp { PlanarWarp() : GenericWarp(), Orientation_Vector(0.0, 0.0, 1.0), OffSet(0.0) @@ -151,16 +161,16 @@ struct PlanarWarp : public GenericWarp GenericWarp(old), Orientation_Vector(old.Orientation_Vector), OffSet(old.OffSet) {} - virtual GenericWarp* Clone() const { return new PlanarWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new PlanarWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Orientation_Vector; DBL OffSet; }; -struct RepeatWarp : public GenericWarp +struct RepeatWarp final : public GenericWarp { RepeatWarp() : GenericWarp(), Axis(-1), Width(0.0), Flip(1.0), Offset(0.0) @@ -169,35 +179,35 @@ struct RepeatWarp : public GenericWarp GenericWarp(old), Axis(old.Axis), Width(old.Width), Flip(old.Flip), Offset(old.Offset) {} - virtual GenericWarp* Clone() const { return new RepeatWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new RepeatWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; int Axis; SNGL Width; Vector3d Flip, Offset; }; -struct SphericalWarp : public GenericWarp +struct SphericalWarp final : public GenericWarp { SphericalWarp() : GenericWarp(), Orientation_Vector(0.0, 0.0, 1.0), DistExp(0.0) {} SphericalWarp(const SphericalWarp& old) : GenericWarp(old), Orientation_Vector(old.Orientation_Vector), DistExp(old.DistExp) - {} + {} - virtual GenericWarp* Clone() const { return new SphericalWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new SphericalWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Orientation_Vector; DBL DistExp; }; -struct ToroidalWarp : public GenericWarp +struct ToroidalWarp final : public GenericWarp { ToroidalWarp() : GenericWarp(), Orientation_Vector(0.0, 0.0, 1.0), DistExp(0.0), MajorRadius(1.0) @@ -207,17 +217,17 @@ struct ToroidalWarp : public GenericWarp MajorRadius(old.MajorRadius) {} - virtual GenericWarp* Clone() const { return new ToroidalWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new ToroidalWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Orientation_Vector; DBL DistExp; DBL MajorRadius; }; -struct TransformWarp : public GenericWarp +struct TransformWarp final : public GenericWarp { TransformWarp() : GenericWarp() @@ -229,10 +239,10 @@ struct TransformWarp : public GenericWarp GenericWarp(old), Trans(old.Trans) {} - virtual GenericWarp* Clone() const { return new TransformWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new TransformWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; TRANSFORM Trans; }; @@ -247,10 +257,10 @@ struct GenericTurbulenceWarp : public GenericWarp GenericWarp(old), Turbulence(old.Turbulence), Octaves(old.Octaves), Lambda(old.Lambda), Omega(old.Omega) {} - virtual GenericWarp* Clone() const = 0; - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override = 0; + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Turbulence; int Octaves; @@ -258,16 +268,16 @@ struct GenericTurbulenceWarp : public GenericWarp }; /// Genuine turbulence warp. -struct TurbulenceWarp : public GenericTurbulenceWarp +struct TurbulenceWarp final : public GenericTurbulenceWarp { TurbulenceWarp() : GenericTurbulenceWarp() {} TurbulenceWarp(const TurbulenceWarp& old) : GenericTurbulenceWarp(old) {} - virtual GenericWarp* Clone() const { return new TurbulenceWarp(*this); } + virtual GenericWarp* Clone() const override { return new TurbulenceWarp(*this); } }; /// Turbulence tied to a pattern. -struct ClassicTurbulence : public GenericTurbulenceWarp +struct ClassicTurbulence final : public GenericTurbulenceWarp { ClassicTurbulence(bool hbp) : GenericTurbulenceWarp(), handledByPattern(hbp) @@ -276,7 +286,7 @@ struct ClassicTurbulence : public GenericTurbulenceWarp GenericTurbulenceWarp(old), handledByPattern(old.handledByPattern) {} - virtual GenericWarp* Clone() const { return new ClassicTurbulence(*this); } + virtual GenericWarp* Clone() const override { return new ClassicTurbulence(*this); } bool handledByPattern; }; @@ -297,5 +307,6 @@ void UnWarp_Normal (Vector3d& TNorm, const Vector3d& ENorm, const TPATTERN *TPat //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_WARP_H diff --git a/source/core/math/chi2.cpp b/source/core/math/chi2.cpp index c80d03061..d14c9b961 100644 --- a/source/core/math/chi2.cpp +++ b/source/core/math/chi2.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -74,8 +74,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/chi2.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -1029,3 +1037,4 @@ static DBL p1evl(DBL x, const DBL coef[], int N) } } +// end of namespace pov diff --git a/source/core/math/chi2.h b/source/core/math/chi2.h index 8dd824b61..860d4a8a0 100644 --- a/source/core/math/chi2.h +++ b/source/core/math/chi2.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + namespace pov { @@ -61,5 +69,6 @@ DBL ndtri(DBL y0); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_CHI2_H diff --git a/source/core/math/hypercomplex.cpp b/source/core/math/hypercomplex.cpp index d5c56115b..47e06515f 100644 --- a/source/core/math/hypercomplex.cpp +++ b/source/core/math/hypercomplex.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,6 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/hypercomplex.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/shape/fractal.h" // TODO - Where should hcmplx.h/hcmplx.cpp go? Are they really math? [trf] #include "core/shape/sphere.h" // TODO - Move sphere intersection function to math code! [trf] @@ -1338,3 +1346,4 @@ void Complex_Pwr (Complex *target, const Complex *source1, const Complex *source } } +// end of namespace pov diff --git a/source/core/math/hypercomplex.h b/source/core/math/hypercomplex.h index 31b5d5afa..94981cd5f 100644 --- a/source/core/math/hypercomplex.h +++ b/source/core/math/hypercomplex.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/vector.h" @@ -59,48 +67,48 @@ typedef void (*COMPLEX_FUNCTION_METHOD) (Complex *, const Complex *, const Compl class HypercomplexBaseFractalRules : public FractalRules { public: - virtual ~HypercomplexBaseFractalRules() {} - virtual bool Bound (const BasicRay&, const Fractal *, DBL *, DBL *) const; + virtual ~HypercomplexBaseFractalRules() override {} + virtual bool Bound (const BasicRay&, const Fractal *, DBL *, DBL *) const override; }; -class HypercomplexFractalRules : public HypercomplexBaseFractalRules +class HypercomplexFractalRules final : public HypercomplexBaseFractalRules { public: - virtual ~HypercomplexFractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~HypercomplexFractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; }; -class HypercomplexFunctionFractalRules : public HypercomplexBaseFractalRules +class HypercomplexFunctionFractalRules final : public HypercomplexBaseFractalRules { public: HypercomplexFunctionFractalRules(COMPLEX_FUNCTION_METHOD fn) : ComplexFunction(fn) {} - virtual ~HypercomplexFunctionFractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~HypercomplexFunctionFractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; protected: COMPLEX_FUNCTION_METHOD ComplexFunction; void HFunc(DBL *xr, DBL *yr, DBL *zr, DBL *wr, DBL x, DBL y, DBL z, DBL w, const Fractal * f) const; }; -class HypercomplexZ3FractalRules : public HypercomplexBaseFractalRules +class HypercomplexZ3FractalRules final : public HypercomplexBaseFractalRules { public: - virtual ~HypercomplexZ3FractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~HypercomplexZ3FractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; }; -class HypercomplexReciprocalFractalRules : public HypercomplexBaseFractalRules +class HypercomplexReciprocalFractalRules final : public HypercomplexBaseFractalRules { public: - virtual ~HypercomplexReciprocalFractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~HypercomplexReciprocalFractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; }; void Complex_Exp (Complex *target, const Complex *source, const Complex *); @@ -127,5 +135,6 @@ void Complex_Div (Complex *target, const Complex *source1, const Complex *source //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_HYPERCOMPLEX_H diff --git a/source/core/math/jitter.cpp b/source/core/math/jitter.cpp index 12596fb64..ff12a2f07 100644 --- a/source/core/math/jitter.cpp +++ b/source/core/math/jitter.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/jitter.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -79,3 +87,4 @@ const float JitterTable[256] = }; } +// end of namespace pov diff --git a/source/core/math/jitter.h b/source/core/math/jitter.h index e1c69ac79..e02db55e7 100644 --- a/source/core/math/jitter.h +++ b/source/core/math/jitter.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + namespace pov { @@ -84,5 +92,6 @@ inline void Jitter2d(DBL x, DBL y, DBL& jx, DBL& jy) //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_JITTER_H diff --git a/source/core/math/matrix.cpp b/source/core/math/matrix.cpp index 714c9e24f..914a70465 100644 --- a/source/core/math/matrix.cpp +++ b/source/core/math/matrix.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/matrix.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -1194,3 +1202,4 @@ void MInvers(MATRIX r, const MATRIX m) } } +// end of namespace pov diff --git a/source/core/math/matrix.h b/source/core/math/matrix.h index 9265e3edb..2e720a25d 100644 --- a/source/core/math/matrix.h +++ b/source/core/math/matrix.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/vector.h" @@ -59,13 +67,12 @@ namespace pov typedef DBL MATRIX[4][4]; ///< @todo Make this obsolete. -typedef struct Transform_Struct TRANSFORM; - -struct Transform_Struct +struct Transform_Struct final { MATRIX matrix; MATRIX inverse; }; +using TRANSFORM = Transform_Struct; ///< @deprecated /***************************************************************************** @@ -118,5 +125,6 @@ int MInvers3(const Matrix3x3& inM, Matrix3x3& outM); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_MATRIX_H diff --git a/source/core/math/polynomialsolver.cpp b/source/core/math/polynomialsolver.cpp index f2ba43a91..d7a79eb5b 100644 --- a/source/core/math/polynomialsolver.cpp +++ b/source/core/math/polynomialsolver.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,6 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/polynomialsolver.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/support/statistics.h" // this must be the last file included @@ -106,7 +114,7 @@ const DBL RELERROR = 1.0e-12; * Local typedefs ******************************************************************************/ -struct polynomial +struct polynomial final { int ord; DBL coef[MAX_ORDER+1]; @@ -1721,3 +1729,4 @@ int Solve_Polynomial(int n, const DBL *c0, DBL *r, int sturm, DBL epsilon, Rende } } +// end of namespace pov diff --git a/source/core/math/polynomialsolver.h b/source/core/math/polynomialsolver.h index 1e299d0c2..c98c70804 100644 --- a/source/core/math/polynomialsolver.h +++ b/source/core/math/polynomialsolver.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + namespace pov { @@ -69,5 +77,6 @@ int Solve_Polynomial (int n, const DBL *c, DBL *r, int sturm, DBL epsilon, Rende //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_POLYNOMIALSOLVER_H diff --git a/source/core/math/quaternion.cpp b/source/core/math/quaternion.cpp index 915ad7fae..ce6479db8 100644 --- a/source/core/math/quaternion.cpp +++ b/source/core/math/quaternion.cpp @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/quaternion.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/shape/fractal.h" #include "core/shape/sphere.h" @@ -566,3 +574,4 @@ bool QuaternionFractalRules::Bound(const BasicRay& ray, const Fractal *fractal, } } +// end of namespace pov diff --git a/source/core/math/quaternion.h b/source/core/math/quaternion.h index 762639606..2ad97646c 100644 --- a/source/core/math/quaternion.h +++ b/source/core/math/quaternion.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/vector.h" @@ -52,7 +60,6 @@ namespace pov /// /// @{ -struct BasicRay; class Fractal; /***************************************************************************** @@ -62,26 +69,26 @@ class Fractal; class QuaternionFractalRules : public FractalRules { public: - virtual ~QuaternionFractalRules() {} - virtual bool Bound (const BasicRay&, const Fractal *, DBL *, DBL *) const; + virtual ~QuaternionFractalRules() override {} + virtual bool Bound (const BasicRay&, const Fractal *, DBL *, DBL *) const override; }; -class JuliaFractalRules : public QuaternionFractalRules +class JuliaFractalRules final : public QuaternionFractalRules { public: - virtual ~JuliaFractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~JuliaFractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; }; -class Z3FractalRules : public QuaternionFractalRules +class Z3FractalRules final : public QuaternionFractalRules { public: - virtual ~Z3FractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~Z3FractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; }; /// @} @@ -89,5 +96,6 @@ class Z3FractalRules : public QuaternionFractalRules //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_QUATERNION_H diff --git a/source/core/math/randcosweighted.cpp b/source/core/math/randcosweighted.cpp index 828872ef8..34f3a6791 100644 --- a/source/core/math/randcosweighted.cpp +++ b/source/core/math/randcosweighted.cpp @@ -13,7 +13,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -48,6 +48,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/randcosweighted.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -1658,4 +1666,4 @@ BYTE_XYZ kaRandCosWeighted[kRandCosWeightedCount] = { }; } - +// end of namespace pov diff --git a/source/core/math/randcosweighted.h b/source/core/math/randcosweighted.h index 58aa9afb0..be293ed96 100644 --- a/source/core/math/randcosweighted.h +++ b/source/core/math/randcosweighted.h @@ -14,7 +14,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,6 +45,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" namespace pov @@ -66,7 +74,7 @@ namespace pov /// /// @{ -struct BYTE_XYZ +struct BYTE_XYZ final { unsigned char x, y, z; }; @@ -92,5 +100,6 @@ inline void VUnpack(Vector3d& dest_vec, const BYTE_XYZ * pack_vec) //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_RANDCOSWEIGHTED_H diff --git a/source/core/math/randomsequence.cpp b/source/core/math/randomsequence.cpp index dc1b70746..512ab8aae 100644 --- a/source/core/math/randomsequence.cpp +++ b/source/core/math/randomsequence.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,12 +36,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/randomsequence.h" -#include +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files #include #include #include +// Boost header files #include #include #include @@ -50,6 +53,10 @@ #include #endif +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/randcosweighted.h" @@ -66,6 +73,9 @@ using boost::uniform_real; using boost::variate_generator; using boost::mt19937; +using std::shared_ptr; +using std::vector; + #define PRIME_TABLE_COUNT 25 unsigned int primeTable[PRIME_TABLE_COUNT] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 }; @@ -118,7 +128,7 @@ vector RandomInts(int minval, int maxval, size_t count) { mt19937 generator; uniform_int distribution(minval, maxval); - variate_generator > sequence(generator, distribution); + variate_generator> sequence(generator, distribution); vector rands(count); for(size_t i = 0; i < count; i++) @@ -131,7 +141,7 @@ vector RandomDoubles(double minval, double maxval, size_t count) { mt19937 generator; uniform_real distribution(minval, maxval); - variate_generator > sequence(generator, distribution); + variate_generator> sequence(generator, distribution); vector rands(count); for(size_t i = 0; i < count; i++) @@ -269,11 +279,11 @@ class HybridNumberGenerator : public SeedableNumberGenerator, public Index public: HybridNumberGenerator(size_t size = 0); - virtual Type operator()(); - virtual shared_ptr > GetSequence(size_t count); - virtual size_t MaxIndex() const; - virtual size_t CycleLength() const; - virtual void Seed(size_t seed); + virtual Type operator()() override; + virtual shared_ptr> GetSequence(size_t count) override; + virtual size_t MaxIndex() const override; + virtual size_t CycleLength() const override; + virtual void Seed(size_t seed) override; protected: @@ -294,7 +304,8 @@ class UniformRandomNumberGenerator : public SeedableNumberGenerator { public: - struct ParameterStruct { + struct ParameterStruct final + { ParameterStruct(Type minval, Type maxval); Type minval, maxval; bool operator< (const ParameterStruct& other) const; @@ -302,16 +313,16 @@ class UniformRandomNumberGenerator : public SeedableNumberGenerator UniformRandomNumberGenerator(const ParameterStruct& param); UniformRandomNumberGenerator(Type minval, Type maxval); - virtual Type operator()(); - virtual size_t CycleLength() const; + virtual Type operator()() override; + virtual size_t CycleLength() const override; virtual void Seed(size_t seed) override; protected: variate_generator generator; }; -typedef UniformRandomNumberGenerator > Mt19937IntGenerator; -typedef UniformRandomNumberGenerator > Mt19937DoubleGenerator; +typedef UniformRandomNumberGenerator> Mt19937IntGenerator; +typedef UniformRandomNumberGenerator> Mt19937DoubleGenerator; /** * Generator for a 1-dimensional Halton sequence (aka van-der-Corput sequence). @@ -333,7 +344,7 @@ class HaltonGenerator : public HybridNumberGenerator HaltonGenerator(const ParameterStruct& param); HaltonGenerator(unsigned int base, Type minval, Type maxval); /// Returns a particular number from the sequence. - virtual double operator[](size_t index) const; + virtual double operator[](size_t index) const override; protected: @@ -366,7 +377,7 @@ class LegacyCosWeightedDirectionGenerator : public HybridNumberGenerator }; Halton2dBasedGenerator(const ParameterStruct& param); - virtual Type operator[](size_t i) const = 0; + virtual Type operator[](size_t i) const override = 0; protected: @@ -409,7 +420,7 @@ class HaltonCosWeightedDirectionGenerator : public Halton2dBasedGenerator }; HaltonOnDiscGenerator(const ParameterStruct& param); - virtual Vector2d operator[](size_t i) const; + virtual Vector2d operator[](size_t i) const override; }; /** @@ -441,7 +452,7 @@ class HaltonUniformDirectionGenerator : public Halton2dBasedGenerator { public: Halton2dGenerator(const ParameterStruct& param); - virtual Vector2d operator[](size_t i) const; + virtual Vector2d operator[](size_t i) const override; }; @@ -470,9 +481,9 @@ class NumberSequenceFactory /// Sets up the factory to use a given sequence. NumberSequenceFactory(shared_ptr const> masterSequence); /// Sets up the factory to use a given number source. - NumberSequenceFactory(shared_ptr > master); + NumberSequenceFactory(shared_ptr> master); /// Sets up the factory to use a given number source, pre-computing a given number of elements. - NumberSequenceFactory(shared_ptr > master, size_t count); + NumberSequenceFactory(shared_ptr> master, size_t count); /// Gets a reference to a table of pre-computed numbers having at least the given size. /// @note The vector returned may contain more elements than requested. shared_ptr const> operator()(size_t count); @@ -505,13 +516,13 @@ class NumberSequenceMetaFactory { public: - static shared_ptr > GetFactory(const typename GeneratorType::ParameterStruct& param); + static shared_ptr> GetFactory(const typename GeneratorType::ParameterStruct& param); protected: typedef NumberSequenceFactory Factory; typedef shared_ptr FactoryPtr; - typedef weak_ptr FactoryWeakPtr; + typedef std::weak_ptr FactoryWeakPtr; typedef std::map FactoryTable; static FactoryTable* lookupTable; @@ -539,24 +550,24 @@ class PrecomputedNumberGenerator : public HybridNumberGenerator public: /// Construct from a sequence factory. - PrecomputedNumberGenerator(shared_ptr > master, size_t size) : + PrecomputedNumberGenerator(shared_ptr> master, size_t size) : HybridNumberGenerator(size), values((*master)(size)) {} /// Returns a particular number from the sequence. - virtual Type operator[](size_t i) const + virtual Type operator[](size_t i) const override { // According to C++ standard, template classes cannot refer to parent template classes' members by unqualified name const size_t& size = HybridNumberGenerator::size; return (*values)[i % size]; } /// Returns a particular subset from the sequence. - virtual shared_ptr > GetSequence(size_t index, size_t count) const + virtual shared_ptr> GetSequence(size_t index, size_t count) const override { // According to C++ standard, template classes cannot refer to parent template classes' members by unqualified name const size_t& size = HybridNumberGenerator::size; - shared_ptr > data(new vector); + shared_ptr> data(new vector); data->reserve(count); size_t i = index % size; while (count >= size - i) // handle wrap-around @@ -600,9 +611,9 @@ Type HybridNumberGenerator::operator()() } template -shared_ptr > HybridNumberGenerator::GetSequence(size_t count) +shared_ptr> HybridNumberGenerator::GetSequence(size_t count) { - shared_ptr > data(IndexedNumberGenerator::GetSequence(index, count)); + shared_ptr> data(IndexedNumberGenerator::GetSequence(index, count)); index += count; if (size != 0) index = index % size; @@ -748,12 +759,12 @@ NumberSequenceFactory::NumberSequenceFactory(shared_ptr const {} template -NumberSequenceFactory::NumberSequenceFactory(shared_ptr > master) : +NumberSequenceFactory::NumberSequenceFactory(shared_ptr> master) : master(master) {} template -NumberSequenceFactory::NumberSequenceFactory(shared_ptr > master, size_t count) : +NumberSequenceFactory::NumberSequenceFactory(shared_ptr> master, size_t count) : master(master) { (*this)(count); // force initial sequence to be generated @@ -802,7 +813,7 @@ shared_ptr const> NumberSequenceFactory::operator()(size_t co *********************************************************************************/ template -std::map > >* NumberSequenceMetaFactory::lookupTable; +std::map>>* NumberSequenceMetaFactory::lookupTable; #if POV_MULTITHREADED template @@ -810,7 +821,7 @@ boost::mutex NumberSequenceMetaFactory::lookupMutex; #endif template -shared_ptr > NumberSequenceMetaFactory::GetFactory(const typename GeneratorType::ParameterStruct& param) +shared_ptr> NumberSequenceMetaFactory::GetFactory(const typename GeneratorType::ParameterStruct& param) { #if POV_MULTITHREADED boost::mutex::scoped_lock lock(lookupMutex); @@ -821,7 +832,7 @@ shared_ptr > NumberSequenceMetaFactory masterGenerator(new GeneratorType(param)); - factory = FactoryPtr(new Factory(shared_ptr >(masterGenerator))); + factory = FactoryPtr(new Factory(shared_ptr>(masterGenerator))); (*lookupTable)[param] = factory; } return factory; @@ -975,7 +986,7 @@ SeedableIntGeneratorPtr GetRandomIntGenerator(int minval, int maxval, size_t cou { POV_RANDOMSEQUENCE_ASSERT(count > 0); Mt19937IntGenerator::ParameterStruct param(minval, maxval); - shared_ptr > factory = Mt19937IntMetaFactory::GetFactory(param); + shared_ptr> factory = Mt19937IntMetaFactory::GetFactory(param); SeedableIntGeneratorPtr generator(new PrecomputedIntGenerator(factory, count)); (void)(*generator)(); // legacy fix return generator; @@ -985,7 +996,7 @@ SeedableDoubleGeneratorPtr GetRandomDoubleGenerator(double minval, double maxval { POV_RANDOMSEQUENCE_ASSERT(count > 0); Mt19937DoubleGenerator::ParameterStruct param(minval, maxval); - shared_ptr > factory(Mt19937DoubleMetaFactory::GetFactory(param)); + shared_ptr> factory(Mt19937DoubleMetaFactory::GetFactory(param)); SeedableDoubleGeneratorPtr generator(new PrecomputedDoubleGenerator(factory, count)); (void)(*generator)(); // legacy fix return generator; @@ -1003,7 +1014,7 @@ IndexedDoubleGeneratorPtr GetIndexedRandomDoubleGenerator(double minval, double { POV_RANDOMSEQUENCE_ASSERT(count > 0); Mt19937DoubleGenerator::ParameterStruct param(minval, maxval); - shared_ptr > factory(Mt19937DoubleMetaFactory::GetFactory(param)); + shared_ptr> factory(Mt19937DoubleMetaFactory::GetFactory(param)); return IndexedDoubleGeneratorPtr(new PrecomputedDoubleGenerator(factory, count)); } @@ -1012,7 +1023,7 @@ SequentialVectorGeneratorPtr GetSubRandomCosWeightedDirectionGenerator(unsigned if ((id == 0) && count && (count < LegacyCosWeightedDirectionGenerator::NumEntries)) { LegacyCosWeightedDirectionGenerator::ParameterStruct param; - shared_ptr > factory(LegacyCosWeightedDirectionMetaFactory::GetFactory(param)); + shared_ptr> factory(LegacyCosWeightedDirectionMetaFactory::GetFactory(param)); return SequentialVectorGeneratorPtr(new PrecomputedVectorGenerator(factory, count)); } else @@ -1020,7 +1031,7 @@ SequentialVectorGeneratorPtr GetSubRandomCosWeightedDirectionGenerator(unsigned HaltonCosWeightedDirectionGenerator::ParameterStruct param(primeTable[id % PRIME_TABLE_COUNT], primeTable[(id+1) % PRIME_TABLE_COUNT]); if (count) { - shared_ptr > factory(HaltonCosWeightedDirectionMetaFactory::GetFactory(param)); + shared_ptr> factory(HaltonCosWeightedDirectionMetaFactory::GetFactory(param)); return SequentialVectorGeneratorPtr(new PrecomputedVectorGenerator(factory, count)); } else @@ -1033,7 +1044,7 @@ SequentialDoubleGeneratorPtr GetSubRandomDoubleGenerator(unsigned int id, double HaltonDoubleGenerator::ParameterStruct param(primeTable[id % PRIME_TABLE_COUNT], minval, maxval); if (count) { - shared_ptr > factory(HaltonUniformDoubleMetaFactory::GetFactory(param)); + shared_ptr> factory(HaltonUniformDoubleMetaFactory::GetFactory(param)); return SequentialDoubleGeneratorPtr(new PrecomputedDoubleGenerator(factory, count)); } else @@ -1045,7 +1056,7 @@ SequentialVectorGeneratorPtr GetSubRandomDirectionGenerator(unsigned int id, siz HaltonUniformDirectionGenerator::ParameterStruct param(primeTable[id % PRIME_TABLE_COUNT], primeTable[(id+1) % PRIME_TABLE_COUNT]); if (count) { - shared_ptr > factory(HaltonUniformDirectionMetaFactory::GetFactory(param)); + shared_ptr> factory(HaltonUniformDirectionMetaFactory::GetFactory(param)); return SequentialVectorGeneratorPtr(new PrecomputedVectorGenerator(factory, count)); } else @@ -1057,7 +1068,7 @@ SequentialVector2dGeneratorPtr GetSubRandomOnDiscGenerator(unsigned int id, doub HaltonOnDiscGenerator::ParameterStruct param(primeTable[id % PRIME_TABLE_COUNT], primeTable[(id+1) % PRIME_TABLE_COUNT], radius); if (count) { - shared_ptr > factory(HaltonOnDiscMetaFactory::GetFactory(param)); + shared_ptr> factory(HaltonOnDiscMetaFactory::GetFactory(param)); return SequentialVector2dGeneratorPtr(new PrecomputedVector2dGenerator(factory, count)); } else @@ -1069,11 +1080,12 @@ SequentialVector2dGeneratorPtr GetSubRandom2dGenerator(unsigned int id, double m Halton2dGenerator::ParameterStruct param(primeTable[id % PRIME_TABLE_COUNT], primeTable[(id+1) % PRIME_TABLE_COUNT], minX, maxX, minY, maxY); if (count) { - shared_ptr > factory(Halton2dMetaFactory::GetFactory(param)); + shared_ptr> factory(Halton2dMetaFactory::GetFactory(param)); return SequentialVector2dGeneratorPtr(new PrecomputedVector2dGenerator(factory, count)); } else return SequentialVector2dGeneratorPtr(new Halton2dGenerator(param)); } -} // end of namespace pov +} +// end of namespace pov diff --git a/source/core/math/randomsequence.h b/source/core/math/randomsequence.h index f507bf8d3..65af6da16 100644 --- a/source/core/math/randomsequence.h +++ b/source/core/math/randomsequence.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/vector.h" namespace pov @@ -53,17 +62,15 @@ namespace pov /// /// @{ -using namespace pov_base; - -vector RandomInts(int minval, int maxval, size_t count); -vector RandomDoubles(int minval, int maxval, size_t count); +std::vector RandomInts(int minval, int maxval, size_t count); +std::vector RandomDoubles(int minval, int maxval, size_t count); DBL POV_rand(unsigned int& next_rand); // need this to prevent VC++ v8 from thinking that Generator refers to boost::Generator class Generator; -class RandomIntSequence +class RandomIntSequence final { friend class Generator; public: @@ -71,7 +78,7 @@ class RandomIntSequence int operator()(size_t seedindex); - class Generator + class Generator final { public: Generator(RandomIntSequence *seq, size_t seedindex = 0); @@ -84,10 +91,10 @@ class RandomIntSequence size_t index; }; private: - vector values; + std::vector values; }; -class RandomDoubleSequence +class RandomDoubleSequence final { friend class Generator; public: @@ -95,7 +102,7 @@ class RandomDoubleSequence double operator()(size_t seedindex); - class Generator + class Generator final { public: Generator(RandomDoubleSequence *seq, size_t seedindex = 0); @@ -108,7 +115,7 @@ class RandomDoubleSequence size_t index; }; private: - vector values; + std::vector values; }; @@ -127,9 +134,9 @@ class SequentialNumberGenerator /// Returns the next number from the sequence. virtual Type operator()() = 0; /// Returns the next N numbers from the sequence. - virtual shared_ptr > GetSequence(size_t count) + virtual std::shared_ptr> GetSequence(size_t count) { - shared_ptr > data(new vector); + std::shared_ptr> data(new std::vector); data->reserve(count); for (size_t i = 0; i < count; i ++) data->push_back((*this)()); @@ -156,9 +163,9 @@ class IndexedNumberGenerator /// Returns a particular number from the sequence. virtual Type operator[](size_t index) const = 0; /// Returns a particular subsequence from the sequence. - virtual shared_ptr > GetSequence(size_t index, size_t count) const + virtual std::shared_ptr> GetSequence(size_t index, size_t count) const { - shared_ptr > data(new vector); + std::shared_ptr> data(new std::vector); data->reserve(count); for (size_t i = 0; i < count; i ++) data->push_back((*this)[index + i]); @@ -180,20 +187,20 @@ class IndexedNumberGenerator /// /// @{ -typedef shared_ptr > SequentialIntGeneratorPtr; -typedef shared_ptr > SequentialDoubleGeneratorPtr; -typedef shared_ptr > SequentialVectorGeneratorPtr; -typedef shared_ptr > SequentialVector2dGeneratorPtr; +typedef std::shared_ptr> SequentialIntGeneratorPtr; +typedef std::shared_ptr> SequentialDoubleGeneratorPtr; +typedef std::shared_ptr> SequentialVectorGeneratorPtr; +typedef std::shared_ptr> SequentialVector2dGeneratorPtr; -typedef shared_ptr > SeedableIntGeneratorPtr; -typedef shared_ptr > SeedableDoubleGeneratorPtr; -typedef shared_ptr > SeedableVectorGeneratorPtr; -typedef shared_ptr > SeedableVector2dGeneratorPtr; +typedef std::shared_ptr> SeedableIntGeneratorPtr; +typedef std::shared_ptr> SeedableDoubleGeneratorPtr; +typedef std::shared_ptr> SeedableVectorGeneratorPtr; +typedef std::shared_ptr> SeedableVector2dGeneratorPtr; -typedef shared_ptr const> IndexedIntGeneratorPtr; -typedef shared_ptr const> IndexedDoubleGeneratorPtr; -typedef shared_ptr const> IndexedVectorGeneratorPtr; -typedef shared_ptr const> IndexedVector2dGeneratorPtr; +typedef std::shared_ptr const> IndexedIntGeneratorPtr; +typedef std::shared_ptr const> IndexedDoubleGeneratorPtr; +typedef std::shared_ptr const> IndexedVectorGeneratorPtr; +typedef std::shared_ptr const> IndexedVector2dGeneratorPtr; /** * @} @@ -363,5 +370,6 @@ SequentialVector2dGeneratorPtr GetSubRandom2dGenerator(unsigned int id, double m //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_RANDOMSEQUENCE_H diff --git a/source/core/math/spline.cpp b/source/core/math/spline.cpp index 7659714ac..0a4f80619 100644 --- a/source/core/math/spline.cpp +++ b/source/core/math/spline.cpp @@ -16,7 +16,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -44,15 +44,22 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/spline.h" +// C++ variants of C standard header files #include #include #include +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/povassert.h" #include "base/types.h" +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -853,3 +860,4 @@ DBL Get_Spline_Val(GenericSpline *sp, DBL p, EXPRESS& v, int *Terms) } } +// end of namespace pov diff --git a/source/core/math/spline.h b/source/core/math/spline.h index 5d0146dd1..f4ad04ed1 100644 --- a/source/core/math/spline.h +++ b/source/core/math/spline.h @@ -16,7 +16,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -47,7 +47,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "base/types.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/base_fwd.h" + +// POV-Ray header files (core module) +// (none at the moment) namespace pov { @@ -61,14 +71,14 @@ using namespace pov_base; /// /// @{ -struct SplineEntry +struct SplineEntry final { DBL par; // Parameter EXPRESS vec; // Value at the parameter DBL coeff[5]; // Interpolating coefficients at the parameter }; -typedef vector SplineEntryList; +typedef std::vector SplineEntryList; typedef int SplineRefCount; @@ -88,36 +98,36 @@ struct GenericSpline void ReleaseReference(); }; -struct LinearSpline : public GenericSpline +struct LinearSpline final : public GenericSpline { LinearSpline(); LinearSpline(const GenericSpline& o); - virtual void Get(DBL p, EXPRESS& v); - virtual GenericSpline* Clone() const { return new LinearSpline(*this); } + virtual void Get(DBL p, EXPRESS& v) override; + virtual GenericSpline* Clone() const override { return new LinearSpline(*this); } }; -struct QuadraticSpline : public GenericSpline +struct QuadraticSpline final : public GenericSpline { QuadraticSpline(); QuadraticSpline(const GenericSpline& o); - virtual void Get(DBL p, EXPRESS& v); - virtual GenericSpline* Clone() const { return new QuadraticSpline(*this); } + virtual void Get(DBL p, EXPRESS& v) override; + virtual GenericSpline* Clone() const override { return new QuadraticSpline(*this); } }; -struct NaturalSpline : public GenericSpline +struct NaturalSpline final : public GenericSpline { NaturalSpline(); NaturalSpline(const GenericSpline& o); - virtual void Get(DBL p, EXPRESS& v); - virtual GenericSpline* Clone() const { return new NaturalSpline(*this); } + virtual void Get(DBL p, EXPRESS& v) override; + virtual GenericSpline* Clone() const override { return new NaturalSpline(*this); } }; -struct CatmullRomSpline : public GenericSpline +struct CatmullRomSpline final : public GenericSpline { CatmullRomSpline(); CatmullRomSpline(const GenericSpline& o); - virtual void Get(DBL p, EXPRESS& v); - virtual GenericSpline* Clone() const { return new CatmullRomSpline(*this); } + virtual void Get(DBL p, EXPRESS& v) override; + virtual GenericSpline* Clone() const override { return new CatmullRomSpline(*this); } }; @@ -135,5 +145,6 @@ DBL Get_Spline_Val(GenericSpline* sp, DBL p, EXPRESS& v, int *Terms); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SPLINE_H diff --git a/source/core/math/vector.cpp b/source/core/math/vector.cpp new file mode 100644 index 000000000..6789e5c69 --- /dev/null +++ b/source/core/math/vector.cpp @@ -0,0 +1,100 @@ +//****************************************************************************** +/// +/// @file core/math/vector.cpp +/// +/// Implementations related to vector arithmetics. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "core/math/vector.h" + +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/pov_mem.h" +// POV-Ray header files (core module) +// (none at the moment) + +namespace pov +{ + +//****************************************************************************** + +VECTOR_4D *Create_Vector_4D () +{ + VECTOR_4D *New; + + New = reinterpret_cast(POV_MALLOC(sizeof (VECTOR_4D), "4d vector")); + + (*New)[0]= 0.0; + (*New)[1]= 0.0; + (*New)[2]= 0.0; + (*New)[3]= 0.0; + + return (New); +} + +void Assign_Vector_4D(VECTOR_4D d, const VECTOR_4D s) +{ + d[X] = s[X]; + d[Y] = s[Y]; + d[Z] = s[Z]; + d[T] = s[T]; +} + +void Destroy_Vector_4D(VECTOR_4D *x) +{ + if (x != nullptr) + POV_FREE(x); +} + +// Inverse Scale - Divide Vector by a Scalar +void V4D_InverseScaleEq(VECTOR_4D a, DBL k) +{ + DBL tmp = 1.0 / k; + a[X] *= tmp; + a[Y] *= tmp; + a[Z] *= tmp; + a[T] *= tmp; +} + +// Dot Product - Gives Scalar angle (a) between two vectors (b) and (c) +void V4D_Dot(DBL& a, const VECTOR_4D b, const VECTOR_4D c) +{ + a = b[X] * c[X] + b[Y] * c[Y] + b[Z] * c[Z] + b[T] * c[T]; +} + +//****************************************************************************** + +} +// end of namespace pov diff --git a/source/core/math/vector.h b/source/core/math/vector.h index a581b8226..174868bf7 100644 --- a/source/core/math/vector.h +++ b/source/core/math/vector.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,7 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "base/types.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) namespace pov { @@ -65,56 +73,23 @@ enum W = 3 }; -typedef DBL VECTOR_4D[4]; ///< @todo Make this obsolete. - -/***************************************************************************** -* Inline functions -******************************************************************************/ +//****************************************************************************** -inline VECTOR_4D *Create_Vector_4D () -{ - VECTOR_4D *New; +typedef DBL VECTOR_4D[4]; ///< @todo Make this obsolete. - New = reinterpret_cast(POV_MALLOC(sizeof (VECTOR_4D), "4d vector")); +VECTOR_4D *Create_Vector_4D (); - (*New)[0]= 0.0; - (*New)[1]= 0.0; - (*New)[2]= 0.0; - (*New)[3]= 0.0; +void Assign_Vector_4D(VECTOR_4D d, const VECTOR_4D s); - return (New); -} - -inline void Assign_Vector_4D(VECTOR_4D d, const VECTOR_4D s) -{ - d[X] = s[X]; - d[Y] = s[Y]; - d[Z] = s[Z]; - d[T] = s[T]; -} - -inline void Destroy_Vector_4D(VECTOR_4D *x) -{ - if (x != nullptr) - POV_FREE(x); -} +void Destroy_Vector_4D(VECTOR_4D *x); // Inverse Scale - Divide Vector by a Scalar -inline void V4D_InverseScaleEq(VECTOR_4D a, DBL k) -{ - DBL tmp = 1.0 / k; - a[X] *= tmp; - a[Y] *= tmp; - a[Z] *= tmp; - a[T] *= tmp; -} +void V4D_InverseScaleEq(VECTOR_4D a, DBL k); // Dot Product - Gives Scalar angle (a) between two vectors (b) and (c) -inline void V4D_Dot(DBL& a, const VECTOR_4D b, const VECTOR_4D c) -{ - a = b[X] * c[X] + b[Y] * c[Y] + b[Z] * c[Z] + b[T] * c[T]; -} +void V4D_Dot(DBL& a, const VECTOR_4D b, const VECTOR_4D c); +//****************************************************************************** template class GenericVector3d; @@ -124,7 +99,7 @@ class GenericVector3d; /// @tparam T Floating-point type to use for the individual vector components. /// template -class GenericVector2d +class GenericVector2d final { public: @@ -343,7 +318,7 @@ class GenericVector2d /// @tparam T Floating-point type to use for the individual vector components. /// template -class GenericVector3d +class GenericVector3d final { public: @@ -680,5 +655,6 @@ inline GenericVector3d max(GenericVector3d& a, const GenericVector3d& b } } +// end of namespace pov #endif // POVRAY_CORE_VECTOR_H diff --git a/source/core/precomp.h b/source/core/precomp.h index d412cbd84..35f6028c6 100644 --- a/source/core/precomp.h +++ b/source/core/precomp.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "base/configbase.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,13 +70,12 @@ #include #include +// Boost header files #include #include #include #include #include -#include -#include #if POV_MULTITHREADED #include #include diff --git a/source/core/render/ray.cpp b/source/core/render/ray.cpp index 9f556a3b0..fcf048998 100644 --- a/source/core/render/ray.cpp +++ b/source/core/render/ray.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/render/ray.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/interior.h" // this must be the last file included @@ -158,3 +166,4 @@ void Ray::SetFlags(RayType rt, const Ray& other) } } +// end of namespace pov diff --git a/source/core/render/ray.h b/source/core/render/ray.h index 30afb695a..6f79c07d9 100644 --- a/source/core/render/ray.h +++ b/source/core/render/ray.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,7 +38,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/render/ray_fwd.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/core_fwd.h" #include "core/bounding/boundingbox.h" #include "core/colour/spectral.h" #include "core/support/simplevector.h" @@ -52,11 +62,9 @@ namespace pov /// /// @{ -class Interior; - typedef PooledSimpleVector RayInteriorVector; -class Ray : public BasicRay +class Ray final : public BasicRay { public: @@ -128,5 +136,6 @@ class Ray : public BasicRay //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_RAY_H diff --git a/source/core/render/ray_fwd.h b/source/core/render/ray_fwd.h new file mode 100644 index 000000000..800e4140c --- /dev/null +++ b/source/core/render/ray_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file core/render/ray_fwd.h +/// +/// Forward declarations related to rays. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_CORE_RAY_FWD_H +#define POVRAY_CORE_RAY_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class Ray; + +} +// end of namespace pov + +#endif // POVRAY_CORE_RAY_FWD_H diff --git a/source/core/render/trace.cpp b/source/core/render/trace.cpp index 3de25937f..468dd2c49 100644 --- a/source/core/render/trace.cpp +++ b/source/core/render/trace.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,10 +36,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/render/trace.h" +// C++ variants of C standard header files #include +// C++ standard header files +#include + +// Boost header files #include +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) #include "core/bounding/bsptree.h" #include "core/lighting/lightsource.h" #include "core/lighting/radiosity.h" @@ -67,6 +76,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + #define SHADOW_TOLERANCE 1.0e-3 @@ -83,7 +96,7 @@ bool NoSomethingFlagRayObjectCondition::operator()(const Ray& ray, ConstObjectPt return true; } -Trace::Trace(shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, +Trace::Trace(std::shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, CooperateFunctor& cf, MediaFunctor& mf, RadiosityFunctor& rf) : threadData(td), sceneData(sd), @@ -749,7 +762,7 @@ void Trace::ComputeLightedTexture(MathColour& resultColour, ColourChannel& resul MathColour ambBackCol; bool one_colour_found, colour_found; bool tir_occured; - std::auto_ptr surfacePhotonGatherer(nullptr); // TODO FIXME - auto_ptr why? [CLi] why, to auto-destruct it of course! (e.g. in case of exception) + std::unique_ptr surfacePhotonGatherer(nullptr); double relativeIor; ComputeRelativeIOR(ray, isect.Object->interior.get(), relativeIor); @@ -1927,14 +1940,14 @@ void Trace::TraceShadowRay(const LightSource &lightsource, double depth, Ray& li // to link the exe, complaining of an unresolved external. // // TODO: try moving it back in at some point in the future. -struct NoShadowFlagRayObjectCondition : public RayObjectCondition +struct NoShadowFlagRayObjectCondition final : public RayObjectCondition { - virtual bool operator()(const Ray&, ConstObjectPtr object, double) const { return !Test_Flag(object, NO_SHADOW_FLAG); } + virtual bool operator()(const Ray&, ConstObjectPtr object, double) const override { return !Test_Flag(object, NO_SHADOW_FLAG); } }; -struct SmallToleranceRayObjectCondition : public RayObjectCondition +struct SmallToleranceRayObjectCondition final : public RayObjectCondition { - virtual bool operator()(const Ray&, ConstObjectPtr, double dist) const { return dist > SMALL_TOLERANCE; } + virtual bool operator()(const Ray&, ConstObjectPtr, double dist) const override { return dist > SMALL_TOLERANCE; } }; void Trace::TracePointLightShadowRay(const LightSource &lightsource, double& lightsourcedepth, Ray& lightsourceray, MathColour& lightcolour) @@ -3884,4 +3897,5 @@ void Trace::ComputeSubsurfaceScattering(const FINISH *Finish, const MathColour& Eye.GetTicket().subsurfaceRecursionDepth--; } -} // end of namespace +} +// end of namespace pov diff --git a/source/core/render/trace.h b/source/core/render/trace.h index 3b9ed2145..e45a4a7d8 100644 --- a/source/core/render/trace.h +++ b/source/core/render/trace.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,11 +39,22 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/coretypes.h" #include "core/bounding/bsptree.h" #include "core/math/randomsequence.h" #include "core/render/ray.h" +#include "core/scene/atmosphere_fwd.h" namespace pov { @@ -55,18 +66,14 @@ namespace pov /// /// @{ -typedef struct Fog_Struct FOG; class PhotonGatherer; -class SceneData; -class Task; -class ViewData; -struct NoSomethingFlagRayObjectCondition : public RayObjectCondition +struct NoSomethingFlagRayObjectCondition final : public RayObjectCondition { - virtual bool operator()(const Ray& ray, ConstObjectPtr object, double) const; + virtual bool operator()(const Ray& ray, ConstObjectPtr object, double) const override; }; -struct LitInterval +struct LitInterval final { bool lit; double s0, s1, ds; @@ -78,7 +85,7 @@ struct LitInterval lit(nlit), s0(ns0), s1(ns1), ds(ns1 - ns0), l0(nl0), l1(nl1) { } }; -struct MediaInterval +struct MediaInterval final { bool lit; int samples; @@ -98,7 +105,7 @@ struct MediaInterval bool operator<(const MediaInterval& other) const { return (s0 < other.s0); } }; -struct LightSourceIntersectionEntry +struct LightSourceIntersectionEntry final { double s; size_t l; @@ -112,7 +119,7 @@ struct LightSourceIntersectionEntry bool operator<(const LightSourceIntersectionEntry& other) const { return (s < other.s); } }; -struct LightSourceEntry +struct LightSourceEntry final { double s0, s1; LightSource *light; @@ -135,7 +142,7 @@ typedef PooledSimpleVector LightSourceEntryVector; -struct TraceTicket +struct TraceTicket final { /// trace recursion level unsigned int traceLevel; @@ -187,13 +194,15 @@ class Trace class CooperateFunctor { public: + virtual ~CooperateFunctor() {} virtual void operator()() { } }; class MediaFunctor { public: - virtual void ComputeMedia(vector&, const Ray&, Intersection&, MathColour&, ColourChannel&) { } + virtual ~MediaFunctor() {} + virtual void ComputeMedia(std::vector&, const Ray&, Intersection&, MathColour&, ColourChannel&) { } virtual void ComputeMedia(const RayInteriorVector&, const Ray&, Intersection&, MathColour&, ColourChannel&) { } virtual void ComputeMedia(MediaVector&, const Ray&, Intersection&, MathColour&, ColourChannel&) { } }; @@ -201,12 +210,13 @@ class Trace class RadiosityFunctor { public: + virtual ~RadiosityFunctor() {} virtual void ComputeAmbient(const Vector3d& ipoint, const Vector3d& raw_normal, const Vector3d& layer_normal, double brilliance, MathColour& ambient_colour, double weight, TraceTicket& ticket) { } virtual bool CheckRadiosityTraceLevel(const TraceTicket& ticket) { return false; } }; /// @todo TraceThreadData already holds a reference to SceneData. - Trace(shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, + Trace(std::shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, CooperateFunctor& cf, MediaFunctor& mf, RadiosityFunctor& af); virtual ~Trace(); @@ -254,7 +264,7 @@ class Trace protected: // TODO FIXME - should be private /// Structure used to cache reflection information for multi-layered textures. - struct WNRX + struct WNRX final { double weight; Vector3d normal; @@ -265,23 +275,23 @@ class Trace weight(w), normal(n), reflec(r), reflex(x) { } }; - typedef vector TextureVectorData; + typedef std::vector TextureVectorData; typedef RefPool TextureVectorPool; - typedef Ref > TextureVector; + typedef Ref> TextureVector; - typedef vector WNRXVectorData; + typedef std::vector WNRXVectorData; typedef RefPool WNRXVectorPool; - typedef Ref > WNRXVector; + typedef Ref> WNRXVector; /// Structure used to cache shadow test results for complex textures. - struct LightColorCache + struct LightColorCache final { bool tested; MathColour colour; }; - typedef vector LightColorCacheList; - typedef vector LightColorCacheListList; + typedef std::vector LightColorCacheList; + typedef std::vector LightColorCacheListList; /// List (well really vector) of lists of LightColorCaches. /// Each list is expected to have as many elements as there are global light sources. @@ -292,7 +302,7 @@ class Trace int lightColorCacheIndex; /// Scene data. - shared_ptr sceneData; + std::shared_ptr sceneData; /// Maximum trace recursion level found. unsigned int maxFoundTraceLevel; @@ -304,7 +314,7 @@ class Trace /// BSP tree mailbox. BSPTree::Mailbox mailbox; /// Area light grid buffer. - vector lightGrid; + std::vector lightGrid; /// Fast stack pool. IStackPool stackPool; /// Fast texture list pool. @@ -312,9 +322,9 @@ class Trace /// Fast WNRX list pool. WNRXVectorPool wnrxPool; /// Light source shadow cache for shadow tests of first trace level intersections. - vector lightSourceLevel1ShadowCache; + std::vector lightSourceLevel1ShadowCache; /// Light source shadow cache for shadow tests of higher trace level intersections. - vector lightSourceOtherShadowCache; + std::vector lightSourceOtherShadowCache; /// `crand` random number generator. unsigned int crandRandomNumberGenerator; /// Pseudo-random number sequence. @@ -322,11 +332,11 @@ class Trace /// Pseudo-random number generator based on random number sequence. RandomDoubleSequence::Generator randomNumberGenerator; /// Sub-random uniform 3d points on sphere sequence. - vector ssltUniformDirectionGenerator; + std::vector ssltUniformDirectionGenerator; /// Sub-random uniform numbers sequence. - vector ssltUniformNumberGenerator; + std::vector ssltUniformNumberGenerator; /// Sub-random cos-weighted 3d points on hemisphere sequence. - vector ssltCosWeightedDirectionGenerator; + std::vector ssltCosWeightedDirectionGenerator; /// Thread data. TraceThreadData *threadData; @@ -385,7 +395,7 @@ class Trace /// @param[in] shadowflag Whether to perform only computations necessary for shadow testing. /// @param[in] photonpass Whether to deposit photons instead of computing a colour. /// - void ComputeOneTextureColour(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, vector& warps, + void ComputeOneTextureColour(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, std::vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, Ray& ray, COLC weight, Intersection& isect, bool shadowflag, bool photonpass); @@ -411,7 +421,7 @@ class Trace /// @param[in] shadowflag Whether to perform only computations necessary for shadow testing. /// @param[in] photonpass Whether to deposit photons instead of computing a colour. /// - void ComputeAverageTextureColours(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, vector& warps, + void ComputeAverageTextureColours(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, std::vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, Ray& ray, COLC weight, Intersection& isect, bool shadowflag, bool photonpass); @@ -438,7 +448,7 @@ class Trace /// @param[in] weight Importance of this computation. /// @param[in] isect Intersection information. /// - virtual void ComputeLightedTexture(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, vector& warps, + virtual void ComputeLightedTexture(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, std::vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, Ray& ray, COLC weight, Intersection& isect); @@ -459,7 +469,7 @@ class Trace /// @param[in,out] ray Ray and associated information. /// @param[in] isect Intersection information. /// - void ComputeShadowTexture(MathColour& filtercolour, const TEXTURE *texture, vector& warps, + void ComputeShadowTexture(MathColour& filtercolour, const TEXTURE *texture, std::vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, const Ray& ray, Intersection& isect); @@ -823,5 +833,6 @@ class Trace //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TRACE_H diff --git a/source/core/render/tracepixel.cpp b/source/core/render/tracepixel.cpp index 58bb16910..32a8abcba 100644 --- a/source/core/render/tracepixel.cpp +++ b/source/core/render/tracepixel.cpp @@ -13,7 +13,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,10 +41,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/render/tracepixel.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include +// POV-Ray header files (base module) +#include +// POV-Ray header files (core module) #include "core/material/normal.h" #include "core/material/pigment.h" #include "core/math/chi2.h" @@ -62,6 +68,9 @@ namespace pov { +using std::min; +using std::max; + #ifdef DYNAMIC_HASHTABLE extern unsigned short *hashTable; // GLOBAL VARIABLE #else @@ -192,7 +201,7 @@ bool ContainingInteriorsPointObjectCondition::operator()(const Vector3d& point, } -TracePixel::TracePixel(shared_ptr sd, const Camera* cam, TraceThreadData *td, unsigned int mtl, DBL adcb, const QualityFlags& qf, +TracePixel::TracePixel(std::shared_ptr sd, const Camera* cam, TraceThreadData *td, unsigned int mtl, DBL adcb, const QualityFlags& qf, CooperateFunctor& cf, MediaFunctor& mf, RadiosityFunctor& af, bool pt) : Trace(sd, td, qf, cf, mf, af), sceneData(sd), @@ -934,13 +943,13 @@ void TracePixel::InitRayContainerState(Ray& ray, bool compute) (*sceneData->tree)(ray.Origin, ifn, mailbox); // test infinite objects - for(vector::iterator object = sceneData->objects.begin() + sceneData->numberOfFiniteObjects; object != sceneData->objects.end(); object++) + for(std::vector::iterator object = sceneData->objects.begin() + sceneData->numberOfFiniteObjects; object != sceneData->objects.end(); object++) if (((*object)->interior != nullptr) && Inside_BBox(ray.Origin, (*object)->BBox) && (*object)->Inside(ray.Origin, threadData)) containingInteriors.push_back((*object)->interior.get()); } else if ((sceneData->boundingMethod == 0) || (sceneData->boundingSlabs == nullptr)) { - for(vector::iterator object = sceneData->objects.begin(); object != sceneData->objects.end(); object++) + for(std::vector::iterator object = sceneData->objects.begin(); object != sceneData->objects.end(); object++) if (((*object)->interior != nullptr) && Inside_BBox(ray.Origin, (*object)->BBox) && (*object)->Inside(ray.Origin, threadData)) containingInteriors.push_back((*object)->interior.get()); } @@ -1240,10 +1249,10 @@ TracePixel::FocalBlurData::FocalBlurData(const Camera& camera, TraceThreadData* int Grid_Size = 2 * (int)ceil(minGridRadius) + 1; // Allocate temporary grid. - boost::scoped_array Grid_Data (new char [Grid_Size * Grid_Size]); + std::unique_ptr Grid_Data (new char [Grid_Size * Grid_Size]); char *p = Grid_Data.get(); memset(p, 0, Grid_Size * Grid_Size); - vector Grid(Grid_Size); + std::vector Grid(Grid_Size); for(int i = 0; i < Grid_Size; i++, p += Grid_Size) Grid[i] = p; @@ -1302,3 +1311,4 @@ TracePixel::FocalBlurData::~FocalBlurData() } } +// end of namespace pov diff --git a/source/core/render/tracepixel.h b/source/core/render/tracepixel.h index 69370a995..9e94a6c71 100644 --- a/source/core/render/tracepixel.h +++ b/source/core/render/tracepixel.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/render/trace.h" #include "core/scene/camera.h" #include "core/scene/scenedata.h" @@ -55,24 +63,24 @@ namespace pov /// /// @{ -struct HasInteriorPointObjectCondition : public PointObjectCondition +struct HasInteriorPointObjectCondition final : public PointObjectCondition { - virtual bool operator()(const Vector3d& point, ConstObjectPtr object) const; + virtual bool operator()(const Vector3d& point, ConstObjectPtr object) const override; }; -struct ContainingInteriorsPointObjectCondition : public PointObjectCondition +struct ContainingInteriorsPointObjectCondition final : public PointObjectCondition { ContainingInteriorsPointObjectCondition(RayInteriorVector& ci) : containingInteriors(ci) {} - virtual bool operator()(const Vector3d& point, ConstObjectPtr object) const; + virtual bool operator()(const Vector3d& point, ConstObjectPtr object) const override; RayInteriorVector &containingInteriors; }; -class TracePixel : public Trace +class TracePixel final : public Trace { public: - TracePixel(shared_ptr sd, const Camera* cam, TraceThreadData *td, unsigned int mtl, DBL adcb, const QualityFlags& qf, + TracePixel(std::shared_ptr sd, const Camera* cam, TraceThreadData *td, unsigned int mtl, DBL adcb, const QualityFlags& qf, CooperateFunctor& cf, MediaFunctor& mf, RadiosityFunctor& af, bool pt = false); - virtual ~TracePixel(); + virtual ~TracePixel() override; void SetupCamera(const Camera& cam); /// Trace a pixel or sub-pixel. @@ -84,7 +92,7 @@ class TracePixel : public Trace void operator()(DBL x, DBL y, DBL width, DBL height, RGBTColour& colour); private: // Focal blur data - class FocalBlurData + class FocalBlurData final { public: FocalBlurData(const Camera& camera, TraceThreadData* threadData); @@ -124,7 +132,7 @@ class TracePixel : public Trace /// camera Camera camera; /// scene data - shared_ptr sceneData; + std::shared_ptr sceneData; /// thread data TraceThreadData *threadData; @@ -153,5 +161,6 @@ class TracePixel : public Trace //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TRACEPIXEL_H diff --git a/source/core/scene/atmosphere.cpp b/source/core/scene/atmosphere.cpp index 40483ab63..549e3e512 100644 --- a/source/core/scene/atmosphere.cpp +++ b/source/core/scene/atmosphere.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/scene/atmosphere.h" -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/pattern.h" #include "core/material/warp.h" #include "core/material/pigment.h" @@ -418,7 +424,7 @@ SKYSPHERE *Copy_Skysphere(const SKYSPHERE *Old) // The standard assignment operator of SKYSPHERE has created a shallow copy of the Pigments vector, but we need a // deep copy in case Old gets destroyed. - for (vector::iterator i = New->Pigments.begin(); i != New->Pigments.end(); ++ i) + for (std::vector::iterator i = New->Pigments.begin(); i != New->Pigments.end(); ++ i) { *i = Copy_Pigment(*i); } @@ -464,7 +470,7 @@ void Destroy_Skysphere(SKYSPHERE *Skysphere) Skysphere_Struct::~Skysphere_Struct() { - for (vector::iterator i = Pigments.begin(); i != Pigments.end(); ++ i) + for (std::vector::iterator i = Pigments.begin(); i != Pigments.end(); ++ i) delete *i; Destroy_Transform(Trans); } @@ -634,3 +640,4 @@ void Transform_Skysphere(SKYSPHERE *Skysphere, const TRANSFORM *Trans) } } +// end of namespace pov diff --git a/source/core/scene/atmosphere.h b/source/core/scene/atmosphere.h index ec240a4fb..0d9fb303a 100644 --- a/source/core/scene/atmosphere.h +++ b/source/core/scene/atmosphere.h @@ -2,13 +2,13 @@ /// /// @file core/scene/atmosphere.h /// -/// Declarations related to atmospheric effets and sky spheres. +/// Declarations related to atmospheric effects and sky spheres. /// /// @copyright /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,7 +38,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/scene/atmosphere_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/pigment.h" namespace pov @@ -65,13 +76,9 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct Fog_Struct FOG; -typedef struct Rainbow_Struct RAINBOW; -typedef struct Skysphere_Struct SKYSPHERE; - struct TurbulenceWarp; // full declaration in core/material/warp.h -struct Fog_Struct +struct Fog_Struct final { Fog_Struct(); ~Fog_Struct(); @@ -86,7 +93,7 @@ struct Fog_Struct FOG *Next; }; -struct Rainbow_Struct +struct Rainbow_Struct final { Rainbow_Struct() : Pigment(nullptr), Next(nullptr) {} ~Rainbow_Struct() { if (Pigment) delete Pigment; } @@ -100,13 +107,13 @@ struct Rainbow_Struct RAINBOW *Next; }; -struct Skysphere_Struct +struct Skysphere_Struct final { Skysphere_Struct() : Trans(nullptr) {} ~Skysphere_Struct(); - MathColour Emission; ///< Brightness adjustment. - vector Pigments; ///< Pigment(s) to use. - TRANSFORM * Trans; ///< Skysphere transformation. + MathColour Emission; ///< Brightness adjustment. + std::vector Pigments; ///< Pigment(s) to use. + TRANSFORM* Trans; ///< Skysphere transformation. }; /***************************************************************************** @@ -134,5 +141,6 @@ void Transform_Skysphere (SKYSPHERE *Skysphere, const TRANSFORM *Trans); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_ATMOSPHERE_H diff --git a/source/core/scene/atmosphere_fwd.h b/source/core/scene/atmosphere_fwd.h new file mode 100644 index 000000000..d9db8e4fe --- /dev/null +++ b/source/core/scene/atmosphere_fwd.h @@ -0,0 +1,57 @@ +//****************************************************************************** +/// +/// @file core/scene/atmosphere_fwd.h +/// +/// Forward declarations related to atmospheric effects and sky spheres. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_CORE_ATMOSPHERE_FWD_H +#define POVRAY_CORE_ATMOSPHERE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +struct Fog_Struct; +struct Rainbow_Struct; +struct Skysphere_Struct; + +using FOG = Fog_Struct; ///< @deprecated +using RAINBOW = Rainbow_Struct; ///< @deprecated +using SKYSPHERE = Skysphere_Struct; ///< @deprecated + +} +// end of namespace pov + +#endif // POVRAY_CORE_ATMOSPHERE_FWD_H diff --git a/source/core/scene/camera.cpp b/source/core/scene/camera.cpp index d863d3ea5..8ff3b885c 100644 --- a/source/core/scene/camera.cpp +++ b/source/core/scene/camera.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/scene/camera.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/normal.h" #include "core/material/pigment.h" #include "core/math/matrix.h" @@ -444,3 +452,4 @@ Camera::~Camera() } } +// end of namespace pov diff --git a/source/core/scene/camera.h b/source/core/scene/camera.h index 38bcc8c66..4d83220ae 100644 --- a/source/core/scene/camera.h +++ b/source/core/scene/camera.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/vector.h" #include "core/material/normal.h" @@ -76,7 +86,7 @@ namespace pov * Global typedefs ******************************************************************************/ -class Camera +class Camera final { public: Vector3d Location; @@ -105,10 +115,10 @@ class Camera unsigned int Face_Distribution_Method; // how to associate a pixel to a face within a mesh unsigned int Rays_Per_Pixel; // cast this many rays per pixel; never less than 1 bool Smooth; // if true, interpolate normals for dist #3 - vector Meshes; // list of the meshes to be used as the camera - vector Mesh_Index; // used with distribution #1 to keep track of accumulated meshes - vector U_Xref[10]; // used to speed up location of a matching face for distribution #3 - vector V_Xref[10]; // used to speed up location of a matching face for distribution #3 + std::vector Meshes; // list of the meshes to be used as the camera + std::vector Mesh_Index; // used with distribution #1 to keep track of accumulated meshes + std::vector U_Xref[10]; // used to speed up location of a matching face for distribution #3 + std::vector V_Xref[10]; // used to speed up location of a matching face for distribution #3 DBL Max_Ray_Distance; // if not 0.0, then maximum distance to look along the ray for an intersection // end of mesh camera declarations @@ -130,5 +140,6 @@ class Camera //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_CAMERA_H diff --git a/source/core/scene/object.cpp b/source/core/scene/object.cpp index ccc7b6c84..55a74be24 100644 --- a/source/core/scene/object.cpp +++ b/source/core/scene/object.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/scene/object.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) #include "core/material/interior.h" #include "core/material/texture.h" #include "core/math/matrix.h" @@ -51,6 +61,8 @@ namespace pov { +using std::vector; + template FORCEINLINE bool Intersect_BBox_Dir(const BoundingBox& bbox, const BBoxVector3d& origin, const BBoxVector3d& invdir, BBoxScalar mind, BBoxScalar maxd); @@ -1096,3 +1108,4 @@ FORCEINLINE bool Intersect_BBox_Dir(const BoundingBox& bbox, const BBoxVector3d& } } +// end of namespace pov diff --git a/source/core/scene/object.h b/source/core/scene/object.h index dc246dc34..9ad1efa27 100644 --- a/source/core/scene/object.h +++ b/source/core/scene/object.h @@ -4,13 +4,11 @@ /// /// Declarations related to geometric shapes. /// -/// @note `frame.h` contains other object stuff. -/// /// @copyright /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,14 +39,19 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/messenger_fwd.h" + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/material/texture.h" -namespace pov_base -{ - class GenericMessenger; -} - namespace pov { @@ -174,9 +177,9 @@ class ObjectBase TEXTURE *Texture; TEXTURE *Interior_Texture; InteriorPtr interior; - vector Bound; - vector Clip; - vector LLights; ///< Used for light groups. + std::vector Bound; + std::vector Clip; + std::vector LLights; ///< Used for light groups. BoundingBox BBox; TRANSFORM *Trans; SNGL Ph_Density; @@ -286,7 +289,7 @@ class NonsolidObject : public ObjectBase { public: NonsolidObject(int t) : ObjectBase(t) {} - virtual ObjectPtr Invert(); + virtual ObjectPtr Invert() override; }; /// Abstract base class for compound geometric objects. @@ -298,14 +301,14 @@ class CompoundObject : public ObjectBase public: CompoundObject(int t) : ObjectBase(t) {} CompoundObject(int t, CompoundObject& o, bool transplant) : ObjectBase(t, o, transplant), children(o.children) { if (transplant) o.children.clear(); } - vector children; - virtual ObjectPtr Invert(); + std::vector children; + virtual ObjectPtr Invert() override; }; /// Light source. /// @ingroup PovCoreLightingLightsource -class LightSource : public CompoundObject +class LightSource final : public CompoundObject { public: size_t index; @@ -330,19 +333,19 @@ class LightSource : public CompoundObject bool lightGroupLight : 1; LightSource(); - virtual ~LightSource(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox() {} + virtual ~LightSource() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override {} }; @@ -359,49 +362,49 @@ struct ContainedByShape }; /// Class used for containing inherently infinite objects (isosurface, parametric) in a box. -struct ContainedByBox : public ContainedByShape +struct ContainedByBox final : public ContainedByShape { Vector3d corner1; Vector3d corner2; ContainedByBox() : corner1(-1,-1,-1), corner2(1,1,1) {} - virtual void ComputeBBox(BoundingBox& rBox) const; - virtual bool Intersect(const Ray& ray, const TRANSFORM* pTrans, DBL& rDepth1, DBL& rDepth2, int& rSide1, int& sSide2) const; - virtual bool Inside(const Vector3d& IPoint) const; - virtual void Normal(const Vector3d& IPoint, const TRANSFORM* pTrans, int side, Vector3d& rNormal) const; - virtual ContainedByShape* Copy() const; + virtual void ComputeBBox(BoundingBox& rBox) const override; + virtual bool Intersect(const Ray& ray, const TRANSFORM* pTrans, DBL& rDepth1, DBL& rDepth2, int& rSide1, int& sSide2) const override; + virtual bool Inside(const Vector3d& IPoint) const override; + virtual void Normal(const Vector3d& IPoint, const TRANSFORM* pTrans, int side, Vector3d& rNormal) const override; + virtual ContainedByShape* Copy() const override; }; /// Class used for containing inherently infinite objects (isosurface, parametric) in a sphere. -struct ContainedBySphere : public ContainedByShape +struct ContainedBySphere final : public ContainedByShape { Vector3d center; DBL radius; ContainedBySphere() : center(0,0,0), radius(1) {} - virtual void ComputeBBox(BoundingBox& rBox) const; - virtual bool Intersect(const Ray& ray, const TRANSFORM* pTrans, DBL& rDepth1, DBL& rDepth2, int& rSide1, int& sSide2) const; - virtual bool Inside(const Vector3d& IPoint) const; - virtual void Normal(const Vector3d& IPoint, const TRANSFORM* pTrans, int side, Vector3d& rNormal) const; - virtual ContainedByShape* Copy() const; + virtual void ComputeBBox(BoundingBox& rBox) const override; + virtual bool Intersect(const Ray& ray, const TRANSFORM* pTrans, DBL& rDepth1, DBL& rDepth2, int& rSide1, int& sSide2) const override; + virtual bool Inside(const Vector3d& IPoint) const override; + virtual void Normal(const Vector3d& IPoint, const TRANSFORM* pTrans, int side, Vector3d& rNormal) const override; + virtual ContainedByShape* Copy() const override; }; bool Find_Intersection(Intersection *Ray_Intersection, ObjectPtr Object, const Ray& ray, TraceThreadData *Thread); bool Find_Intersection(Intersection *Ray_Intersection, ObjectPtr Object, const Ray& ray, const RayObjectCondition& postcondition, TraceThreadData *Thread); bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, BBoxDirection variant, const BBoxVector3d& origin, const BBoxVector3d& invdir, TraceThreadData *ThreadData); bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, BBoxDirection variant, const BBoxVector3d& origin, const BBoxVector3d& invdir, const RayObjectCondition& postcondition, TraceThreadData *ThreadData); -bool Ray_In_Bound(const Ray& ray, const vector& Bounding_Object, TraceThreadData *Thread); -bool Point_In_Clip(const Vector3d& IPoint, const vector& Clip, TraceThreadData *Thread); +bool Ray_In_Bound(const Ray& ray, const std::vector& Bounding_Object, TraceThreadData *Thread); +bool Point_In_Clip(const Vector3d& IPoint, const std::vector& Clip, TraceThreadData *Thread); ObjectPtr Copy_Object(ObjectPtr Old); -vector Copy_Objects(vector& Src); +std::vector Copy_Objects(std::vector& Src); void Translate_Object(ObjectPtr Object, const Vector3d& Vector, const TRANSFORM *Trans); void Rotate_Object(ObjectPtr Object, const Vector3d& Vector, const TRANSFORM *Trans); void Scale_Object(ObjectPtr Object, const Vector3d& Vector, const TRANSFORM *Trans); void Transform_Object(ObjectPtr Object, const TRANSFORM *Trans); bool Inside_Object(const Vector3d& IPoint, ObjectPtr Object, TraceThreadData *Thread); -void Destroy_Object(vector& Object); +void Destroy_Object(std::vector& Object); void Destroy_Object(ObjectPtr Object); void Destroy_Single_Object(ObjectPtr *ObjectPtr); @@ -410,5 +413,6 @@ void Destroy_Single_Object(ObjectPtr *ObjectPtr); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_OBJECT_H diff --git a/source/core/scene/scenedata.cpp b/source/core/scene/scenedata.cpp index 6e7132280..2b93c3edf 100644 --- a/source/core/scene/scenedata.cpp +++ b/source/core/scene/scenedata.cpp @@ -36,14 +36,23 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/scene/scenedata.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// Boost header files #include +// POV-Ray header files (base module) +#include "base/types.h" #include "base/version_info.h" +#include "base/image/colourspace.h" -#include "core/material/pattern.h" +// POV-Ray header files (core module) #include "core/material/noise.h" +#include "core/material/pattern.h" #include "core/scene/atmosphere.h" // this must be the last file included @@ -120,7 +129,7 @@ SceneData::~SceneData() } if (boundingSlabs != nullptr) Destroy_BBox_Tree(boundingSlabs); - for (vector::iterator i = TTFonts.begin(); i != TTFonts.end(); ++i) + for (std::vector::iterator i = TTFonts.begin(); i != TTFonts.end(); ++i) delete *i; // TODO: perhaps ObjectBase::~ObjectBase would be a better place // to handle cleanup of individual objects ? @@ -131,3 +140,4 @@ SceneData::~SceneData() } } +// end of namespace pov diff --git a/source/core/scene/scenedata.h b/source/core/scene/scenedata.h index 61e92272d..b93f77fee 100644 --- a/source/core/scene/scenedata.h +++ b/source/core/scene/scenedata.h @@ -39,11 +39,20 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include +#include -#include "base/image/colourspace.h" +// POV-Ray header files (base module) +#include "base/image/colourspace_fwd.h" +// POV-Ray header files (core module) #include "core/lighting/radiosity.h" +#include "core/scene/atmosphere_fwd.h" #include "core/scene/camera.h" #include "core/shape/truetype.h" @@ -60,10 +69,6 @@ using namespace pov_base; class BSPTree; -struct Fog_Struct; -struct Rainbow_Struct; -struct Skysphere_Struct; - /// Class holding scene specific data. /// /// "For private use by Scene, View and Renderer classes only! @@ -80,17 +85,17 @@ class SceneData { public: - typedef std::map DeclaredVariablesMap; + typedef std::map DeclaredVariablesMap; /// Destructor. - ~SceneData(); + virtual ~SceneData(); /// list of all shape objects - vector objects; + std::vector objects; /// list of all global light sources - vector lightSources; + std::vector lightSources; /// list of all lights that are part of light groups - vector lightGroupLightSources; + std::vector lightGroupLightSources; /// factory generating contexts for legacy VM-based functions in scene GenericFunctionContextFactoryIPtr functionContextFactory; /// atmosphere index of refraction @@ -98,7 +103,7 @@ class SceneData /// atmosphere dispersion DBL atmosphereDispersion; /// atmospheric media - vector atmosphere; + std::vector atmosphere; /// background color - TODO - allow pattern here (useful for background image maps) [trf] TransColour backgroundColour; // may have a filter/transmit component (but filter is ignored) /// ambient light in scene @@ -190,7 +195,7 @@ class SceneData // TODO - decide if we want to keep this here // (we can't move it to the parser though, as part of the data needs to survive into rendering) - vector TTFonts; + std::vector TTFonts; // name of the parsed file UCS2String inputFile; // TODO - handle differently @@ -205,7 +210,7 @@ class SceneData DeclaredVariablesMap declaredVariables; // TODO - move to parser Camera parsedCamera; // TODO - handle differently or move to parser bool clocklessAnimation; // TODO - this is support for an experimental feature and may be changed or removed - vector cameras; // TODO - this is support for an experimental feature and may be changed or removed + std::vector cameras; // TODO - this is support for an experimental feature and may be changed or removed // this is for fractal support int Fractal_Iteration_Stack_Length; // TODO - move somewhere else @@ -252,11 +257,8 @@ class SceneData private: - /// not available - SceneData(const SceneData&); - - /// not available - SceneData& operator=(const SceneData&); + SceneData(const SceneData&) = delete; + SceneData& operator=(const SceneData&) = delete; }; /// @} @@ -264,5 +266,6 @@ class SceneData //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SCENEDATA_H diff --git a/source/core/scene/tracethreaddata.cpp b/source/core/scene/tracethreaddata.cpp index fb060b32e..203d87b51 100644 --- a/source/core/scene/tracethreaddata.cpp +++ b/source/core/scene/tracethreaddata.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/scene/tracethreaddata.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/noise.h" #include "core/scene/scenedata.h" #include "core/shape/blob.h" @@ -50,7 +58,7 @@ namespace pov { -TraceThreadData::TraceThreadData(shared_ptr sd, size_t seed) : +TraceThreadData::TraceThreadData(std::shared_ptr sd, size_t seed) : sceneData(sd), qualityFlags(9), stochasticRandomGenerator(GetRandomDoubleGenerator(0.0,1.0)), @@ -86,7 +94,7 @@ TraceThreadData::TraceThreadData(shared_ptr sd, size_t seed) : stochasticRandomGenerator->Seed(stochasticRandomSeedBase); - for(vector::iterator it = sceneData->lightSources.begin(); it != sceneData->lightSources.end(); it++) + for(std::vector::iterator it = sceneData->lightSources.begin(); it != sceneData->lightSources.end(); it++) lightSources.push_back(static_cast (Copy_Object(*it))); // all of these are for photons @@ -120,7 +128,7 @@ TraceThreadData::TraceThreadData(shared_ptr sd, size_t seed) : TraceThreadData::~TraceThreadData() { - for(vector::iterator i = functionContextPool.begin(); i != functionContextPool.end(); ++i) + for(std::vector::iterator i = functionContextPool.begin(); i != functionContextPool.end(); ++i) delete *i; POV_FREE(Blob_Coefficients); @@ -130,7 +138,7 @@ TraceThreadData::~TraceThreadData() delete surfacePhotonMap; delete mediaPhotonMap; delete[] Blob_Intervals; - for(vector::iterator it = lightSources.begin(); it != lightSources.end(); it++) + for(std::vector::iterator it = lightSources.begin(); it != lightSources.end(); it++) Destroy_Object(*it); } @@ -172,3 +180,4 @@ void TraceThreadData::AfterTile() } } +// end of namespace pov diff --git a/source/core/scene/tracethreaddata.h b/source/core/scene/tracethreaddata.h index 211541c6e..b7c0c76fd 100644 --- a/source/core/scene/tracethreaddata.h +++ b/source/core/scene/tracethreaddata.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,11 +39,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +#include +// POV-Ray header files (base module) #include "base/types.h" +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/bounding/boundingcylinder.h" #include "core/bounding/bsptree.h" @@ -63,7 +70,6 @@ namespace pov using namespace pov_base; -class SceneData; struct ISO_ThreadData; class PhotonMap; @@ -82,10 +88,10 @@ class TraceThreadData : public ThreadData /// @param sd Scene data defining scene attributes. /// @param seed Seed for the stochastic random number generator; /// should be unique for each render. - TraceThreadData(shared_ptr sd, size_t seed); + TraceThreadData(std::shared_ptr sd, size_t seed); /// Destructor. - ~TraceThreadData(); + virtual ~TraceThreadData() override; /// Get the statistics. /// @return Reference to statistic counters. @@ -100,11 +106,11 @@ class TraceThreadData : public ThreadData int Blob_Coefficient_Count; int Blob_Interval_Count; ISO_ThreadData *isosurfaceData; ///< @todo We may want to move this data block to the isosurface code as a local variable. - vector BCyl_Intervals; - vector BCyl_RInt; - vector BCyl_HInt; + std::vector BCyl_Intervals; + std::vector BCyl_RInt; + std::vector BCyl_HInt; IStackPool stackPool; - vector functionContextPool; + std::vector functionContextPool; int Facets_Last_Seed; int Facets_CVC; Vector3d Facets_Cube[81]; @@ -118,7 +124,7 @@ class TraceThreadData : public ThreadData // to the lightsource object passed to them (this is not confined // just to the area light shadow code). This code ought to be fixed // to treat the lightsource as const, after which this can go away. - vector lightSources; + std::vector lightSources; // all of these are for photons // most of them should be refactored into parameters, return values, or other objects @@ -139,8 +145,8 @@ class TraceThreadData : public ThreadData // data for waves and ripples pattern unsigned int numberOfWaves; - vector waveFrequencies; - vector waveSources; + std::vector waveFrequencies; + std::vector waveSources; /// Called after a rectangle is finished. /// Used for crackle cache expiry. @@ -166,23 +172,19 @@ class TraceThreadData : public ThreadData POV_LONG realTime; QualityFlags qualityFlags; // TODO FIXME - remove again - inline shared_ptr GetSceneData() const { return sceneData; } + inline std::shared_ptr GetSceneData() const { return sceneData; } protected: /// scene data - shared_ptr sceneData; + std::shared_ptr sceneData; /// render statistics RenderStatistics renderStats; private: - /// not available - TraceThreadData(); - - /// not available - TraceThreadData(const TraceThreadData&); - /// not available - TraceThreadData& operator=(const TraceThreadData&); + TraceThreadData() = delete; + TraceThreadData(const TraceThreadData&) = delete; + TraceThreadData& operator=(const TraceThreadData&) = delete; /// current number of Tiles to expire crackle cache entries after size_t CrCache_MaxAge; @@ -195,5 +197,6 @@ class TraceThreadData : public ThreadData //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TRACETHREADDATA_H diff --git a/source/core/shape/bezier.cpp b/source/core/shape/bezier.cpp index 1b1a8a9d3..a57f5ddf0 100644 --- a/source/core/shape/bezier.cpp +++ b/source/core/shape/bezier.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,10 +38,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/bezier.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -52,6 +58,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -2176,3 +2185,4 @@ void BicubicPatch::Compute_Texture_UV(const Vector2d& p, const Vector2d st[4], V } } +// end of namespace pov diff --git a/source/core/shape/bezier.h b/source/core/shape/bezier.h index 0d410e632..41725d7d1 100644 --- a/source/core/shape/bezier.h +++ b/source/core/shape/bezier.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -68,31 +76,31 @@ namespace pov ******************************************************************************/ typedef DBL BEZIER_WEIGHTS[4][4]; -typedef struct Bezier_Node_Struct BEZIER_NODE; -typedef struct Bezier_Child_Struct BEZIER_CHILDREN; -typedef struct Bezier_Vertices_Struct BEZIER_VERTICES; -struct Bezier_Child_Struct +struct Bezier_Node_Struct final { - BEZIER_NODE *Children[4]; + int Node_Type; // Is this an interior node, or a leaf + Vector3d Center; // Center of sphere bounding the (sub)patch + DBL Radius_Squared; // Radius of bounding sphere (squared) + int Count; // # of subpatches associated with this node + void *Data_Ptr; // Either pointer to vertices or pointer to children }; +using BEZIER_NODE = Bezier_Node_Struct; ///< @deprecated -struct Bezier_Vertices_Struct +struct Bezier_Child_Struct final { - float uvbnds[4]; - Vector3d Vertices[4]; + BEZIER_NODE *Children[4]; }; +using BEZIER_CHILDREN = Bezier_Child_Struct; ///< @deprecated -struct Bezier_Node_Struct +struct Bezier_Vertices_Struct final { - int Node_Type; // Is this an interior node, or a leaf - Vector3d Center; // Center of sphere bounding the (sub)patch - DBL Radius_Squared; // Radius of bounding sphere (squared) - int Count; // # of subpatches associated with this node - void *Data_Ptr; // Either pointer to vertices or pointer to children + float uvbnds[4]; + Vector3d Vertices[4]; }; +using BEZIER_VERTICES = Bezier_Vertices_Struct; ///< @deprecated -class BicubicPatch : public NonsolidObject +class BicubicPatch final : public NonsolidObject { public: typedef Vector3d ControlPoints[4][4]; @@ -106,19 +114,19 @@ class BicubicPatch : public NonsolidObject BEZIER_WEIGHTS *Weights; BicubicPatch(); - virtual ~BicubicPatch(); + virtual ~BicubicPatch() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Precompute_Patch_Values(); protected: @@ -152,5 +160,6 @@ class BicubicPatch : public NonsolidObject //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BEZIER_H diff --git a/source/core/shape/blob.cpp b/source/core/shape/blob.cpp index 44dea1b13..6c11a8490 100644 --- a/source/core/shape/blob.cpp +++ b/source/core/shape/blob.cpp @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -97,10 +97,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/blob.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/bounding/boundingsphere.h" #include "core/material/texture.h" @@ -115,6 +122,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -3262,3 +3273,4 @@ void Blob::getLocalIPoint(Vector3d& lip, Intersection *isect) const } } +// end of namespace pov diff --git a/source/core/shape/blob.h b/source/core/shape/blob.h index 6bb3d3598..6d5bfdb06 100644 --- a/source/core/shape/blob.h +++ b/source/core/shape/blob.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingsphere.h" #include "core/scene/object.h" @@ -88,7 +98,7 @@ namespace pov * Global typedefs ******************************************************************************/ -class Blob_Element +class Blob_Element final { public: short Type; /* Type of component: sphere, hemisphere, cylinder */ @@ -104,13 +114,13 @@ class Blob_Element ~Blob_Element(); }; -class Blob_Data +class Blob_Data final { public: - int Number_Of_Components; /* Number of components */ - DBL Threshold; /* Blob threshold */ - vector Entry; /* Array of blob components */ - BSPHERE_TREE *Tree; /* Bounding hierarchy */ + int Number_Of_Components; /* Number of components */ + DBL Threshold; /* Blob threshold */ + std::vector Entry; /* Array of blob components */ + BSPHERE_TREE *Tree; /* Bounding hierarchy */ Blob_Data(int count = 0); ~Blob_Data(); @@ -122,42 +132,42 @@ class Blob_Data int References; /* Number of references */ }; -struct Blob_List_Struct +struct Blob_List_Struct final { Blob_Element elem; /* Current element */ Blob_List_Struct *next; /* Pointer to next element */ }; -struct Blob_Interval_Struct +struct Blob_Interval_Struct final { int type; DBL bound; const Blob_Element *Element; }; -class Blob : public ObjectBase +class Blob final : public ObjectBase { public: Blob_Data *Data; - vector Element_Texture; + std::vector Element_Texture; Blob(); - virtual ~Blob(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual double GetPotential (const Vector3d&, bool subtractThreshold, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual ~Blob() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual double GetPotential (const Vector3d&, bool subtractThreshold, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; virtual bool IsOpaque() const override; - void Determine_Textures(Intersection *, bool, WeightedTextureVector&, TraceThreadData *); + virtual void Determine_Textures(Intersection *, bool, WeightedTextureVector&, TraceThreadData *) override; Blob_List_Struct *Create_Blob_List_Element(); void Create_Blob_Element_Texture_List(Blob_List_Struct *BlobList, int npoints); @@ -196,5 +206,6 @@ class Blob : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BLOB_H diff --git a/source/core/shape/box.cpp b/source/core/shape/box.cpp index 54b6fad89..6e4e96770 100644 --- a/source/core/shape/box.cpp +++ b/source/core/shape/box.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,8 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/box.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -1075,3 +1081,4 @@ bool Box::Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d& } } +// end of namespace pov diff --git a/source/core/shape/box.h b/source/core/shape/box.h index e6b154937..045845030 100644 --- a/source/core/shape/box.h +++ b/source/core/shape/box.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,7 +70,7 @@ namespace pov /// //****************************************************************************** -class Box : public ObjectBase +class Box final : public ObjectBase { public: @@ -82,20 +90,20 @@ class Box : public ObjectBase Vector3d bounds[2]; Box(); - virtual ~Box(); + virtual ~Box() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); - virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; + virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; static bool Intersect(const BasicRay& ray, const TRANSFORM *Trans, const Vector3d& Corner1, const Vector3d& Corner2, DBL *Depth1, DBL *Depth2, int *Side1, int *Side2); }; @@ -105,5 +113,6 @@ class Box : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BOX_H diff --git a/source/core/shape/cone.cpp b/source/core/shape/cone.cpp index a0588892e..f5acc49d0 100644 --- a/source/core/shape/cone.cpp +++ b/source/core/shape/cone.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,8 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/cone.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -1056,3 +1062,4 @@ void Cone::CalcUV(const Vector3d& IPoint, Vector2d& Result) const #endif // POV_ENABLE_CONE_UV } +// end of namespace pov diff --git a/source/core/shape/cone.h b/source/core/shape/cone.h index 9b016569a..27b81ea54 100644 --- a/source/core/shape/cone.h +++ b/source/core/shape/cone.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,9 +70,9 @@ namespace pov /// //****************************************************************************** -class Cone : public ObjectBase +class Cone final : public ObjectBase { - struct CONE_INT + struct CONE_INT final { DBL d; /* Distance of intersection point */ int t; /* Type of intersection: base/cap plane or side */ @@ -77,27 +85,27 @@ class Cone : public ObjectBase DBL dist; ///< Distance to end of cone in canonical coords. Cone(); - virtual ~Cone(); + virtual ~Cone() override; void Cylinder(); - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; #ifdef POV_ENABLE_CONE_UV /// @attention /// UV mapping of this primitive should not be enabled until the primary /// parameterization has been amended so that users have full control over the /// primitive's orientation, rather than just the axis of rotational symmetry. - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; #endif // POV_ENABLE_CONE_UV - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Cone_Data(); void Compute_Cylinder_Data(); @@ -113,5 +121,6 @@ class Cone : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_CONE_H diff --git a/source/core/shape/csg.cpp b/source/core/shape/csg.cpp index 157a1aa75..a6e3c15e1 100644 --- a/source/core/shape/csg.cpp +++ b/source/core/shape/csg.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/csg.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include + +// POV-Ray header files (base module) +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/math/matrix.h" @@ -53,6 +62,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + /***************************************************************************** * Global preprocessor defines ******************************************************************************/ @@ -1020,3 +1033,4 @@ void CSG::Determine_Textures(Intersection *isect, bool hitinside, WeightedTextur } } +// end of namespace pov diff --git a/source/core/shape/csg.h b/source/core/shape/csg.h index 6e775cc48..8287f1365 100644 --- a/source/core/shape/csg.h +++ b/source/core/shape/csg.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,7 +38,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/shape/csg_fwd.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -76,15 +85,15 @@ class CSG : public CompoundObject int do_split; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const { } - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual ObjectPtr Invert() = 0; - virtual void Compute_BBox(); + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override { } + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual ObjectPtr Invert() override = 0; + virtual void Compute_BBox() override; - void Determine_Textures(Intersection *isect, bool hitinside, WeightedTextureVector& textures, TraceThreadData *Threaddata); + virtual void Determine_Textures(Intersection *isect, bool hitinside, WeightedTextureVector& textures, TraceThreadData *Threaddata) override; }; class CSGUnion : public CSG @@ -94,35 +103,35 @@ class CSGUnion : public CSG CSGUnion(int t); CSGUnion(int t, CompoundObject& o, bool transplant) : CSG(t, o, transplant) {} - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual ObjectPtr Invert(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual ObjectPtr Invert() override; }; -class CSGMerge : public CSGUnion +class CSGMerge final : public CSGUnion { public: CSGMerge(); CSGMerge(CompoundObject& o, bool transplant); - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; }; -class CSGIntersection : public CSG +class CSGIntersection final : public CSG { public: CSGIntersection(bool diff); CSGIntersection(bool diff, CompoundObject& o, bool transplant); - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual ObjectPtr Invert(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual ObjectPtr Invert() override; bool isDifference; }; @@ -132,5 +141,6 @@ class CSGIntersection : public CSG //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_CSG_H diff --git a/source/core/shape/csg_fwd.h b/source/core/shape/csg_fwd.h new file mode 100644 index 000000000..40decc76d --- /dev/null +++ b/source/core/shape/csg_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file core/shape/csg_fwd.h +/// +/// Forward declarations related to constructive solid geometry (csg) shapes. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_CORE_CSG_FWD_H +#define POVRAY_CORE_CSG_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class CSG; + +} +// end of namespace pov + +#endif // POVRAY_CORE_CSG_FWD_H diff --git a/source/core/shape/disc.cpp b/source/core/shape/disc.cpp index f96e3df5b..fd84c7fec 100644 --- a/source/core/shape/disc.cpp +++ b/source/core/shape/disc.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,6 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/disc.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -587,3 +595,4 @@ void Disc::Compute_BBox() } } +// end of namespace pov diff --git a/source/core/shape/disc.h b/source/core/shape/disc.h index e1f0b0349..8a9aafebb 100644 --- a/source/core/shape/disc.h +++ b/source/core/shape/disc.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,7 +70,7 @@ namespace pov /// //****************************************************************************** -class Disc : public ObjectBase +class Disc final : public ObjectBase { public: Vector3d center; ///< Center of the disc. @@ -72,22 +80,22 @@ class Disc : public ObjectBase DBL oradius2; ///< Distance from center to outer circle of the disc. Disc(); - virtual ~Disc(); + virtual ~Disc() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; // NOTE: UV mapping of this primitive should not be implemented without also amending // the primary parameterization so that users have full control over the primitive's // orientation, rather than just the normal vector. - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Disc(); protected: @@ -99,5 +107,6 @@ class Disc : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_DISC_H diff --git a/source/core/shape/fractal.cpp b/source/core/shape/fractal.cpp index c7b5e4ffb..9601f3ca1 100644 --- a/source/core/shape/fractal.cpp +++ b/source/core/shape/fractal.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,8 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/fractal.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/hypercomplex.h" #include "core/math/matrix.h" @@ -874,3 +880,4 @@ void Fractal::Free_Iteration_Stack(DBL **IStack) } } +// end of namespace pov diff --git a/source/core/shape/fractal.h b/source/core/shape/fractal.h index ac6b237f3..e2d749d25 100644 --- a/source/core/shape/fractal.h +++ b/source/core/shape/fractal.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/math/vector.h" #include "core/scene/object.h" @@ -87,12 +95,12 @@ namespace pov class Fractal; -struct Complex +struct Complex final { DBL x,y; }; -class Fractal : public ObjectBase +class Fractal final : public ObjectBase { public: Vector3d Center; @@ -109,18 +117,18 @@ class Fractal : public ObjectBase FractalRulesPtr Rules; Fractal(); - virtual ~Fractal(); + virtual ~Fractal() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; static void Free_Iteration_Stack(DBL **IStack); static void Allocate_Iteration_Stack(DBL **IStack, int Len); @@ -133,5 +141,6 @@ class Fractal : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_FRACTAL_H diff --git a/source/core/shape/heightfield.cpp b/source/core/shape/heightfield.cpp index 77d63083a..a91ec7236 100644 --- a/source/core/shape/heightfield.cpp +++ b/source/core/shape/heightfield.cpp @@ -12,7 +12,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -58,10 +58,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/heightfield.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -74,6 +80,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -94,14 +103,14 @@ const DBL HFIELD_TOLERANCE = 1.0e-6; typedef short HF_Normals[3]; -struct HFBlock +struct HFBlock final { int xmin, xmax; int zmin, zmax; DBL ymin, ymax; }; -struct HFData +struct HFData final { int References; int Normals_Height; /* Needed for Destructor */ @@ -2081,3 +2090,4 @@ bool HField::block_traversal(const BasicRay &ray, const Vector3d& Start, IStack } } +// end of namespace pov diff --git a/source/core/shape/heightfield.h b/source/core/shape/heightfield.h index 8404bd391..f5c765cbd 100644 --- a/source/core/shape/heightfield.h +++ b/source/core/shape/heightfield.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -82,7 +90,7 @@ class ImageData; /// then follows the line from one intersection point to the other, testing the two triangles which form the pixel for /// an intersection with the ray at each step. /// -class HField : public ObjectBase +class HField final : public ObjectBase { public: Vector3d bounding_corner1; @@ -90,18 +98,18 @@ class HField : public ObjectBase HFData *Data; HField(); - virtual ~HField(); + virtual ~HField() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_HField(const ImageData *image); protected: @@ -119,5 +127,6 @@ class HField : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_HEIGHTFIELD_H diff --git a/source/core/shape/isosurface.cpp b/source/core/shape/isosurface.cpp index f04d292bc..5bd9bc9e0 100644 --- a/source/core/shape/isosurface.cpp +++ b/source/core/shape/isosurface.cpp @@ -12,7 +12,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,10 +40,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/isosurface.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/messenger.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -54,11 +60,14 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ -struct ISO_Max_Gradient +struct ISO_Max_Gradient final { DBL max_gradient, gradient; DBL eval_max, eval_cnt, eval_gradient_sum, eval_var; @@ -571,7 +580,7 @@ IsoSurface::IsoSurface() : ObjectBase(ISOSURFACE_OBJECT), positivePolarity(false) { - container = shared_ptr(new ContainedByBox()); + container = std::shared_ptr(new ContainedByBox()); Make_BBox(BBox, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0); @@ -591,7 +600,7 @@ IsoSurface::IsoSurface() : gradient = 0.0; threshold = 0.0; - mginfo = intrusive_ptr(new ISO_Max_Gradient()); + mginfo = boost::intrusive_ptr(new ISO_Max_Gradient()); } @@ -635,7 +644,7 @@ ObjectPtr IsoSurface::Copy() New->positivePolarity = positivePolarity; - New->container = shared_ptr(container->Copy()); + New->container = std::shared_ptr(container->Copy()); return (New); } @@ -1040,4 +1049,4 @@ bool IsoSurface::IsInside (GenericScalarFunctionInstance& fn, Vector3d& p) const } } - +// end of namespace pov diff --git a/source/core/shape/isosurface.h b/source/core/shape/isosurface.h index 5d1551dc3..eae370554 100644 --- a/source/core/shape/isosurface.h +++ b/source/core/shape/isosurface.h @@ -12,7 +12,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -43,8 +43,19 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// Boost header files #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/scene/object.h" @@ -80,11 +91,14 @@ class IsoSurface; typedef unsigned char IsosurfaceMaxTrace; -struct ISO_Pair { DBL t,f; }; +struct ISO_Pair final +{ + DBL t, f; +}; struct ISO_Max_Gradient; -struct ISO_ThreadData +struct ISO_ThreadData final { const IsoSurface *current; GenericScalarFunctionInstance* pFn; @@ -97,7 +111,7 @@ struct ISO_ThreadData int Inv3; }; -class IsoSurface : public ObjectBase +class IsoSurface final : public ObjectBase { public: @@ -112,24 +126,24 @@ class IsoSurface : public ObjectBase bool eval : 1; bool positivePolarity : 1; ///< `true` if values above threshold are considered inside, `false` if considered outside. - shared_ptr container; + std::shared_ptr container; IsoSurface(); - virtual ~IsoSurface(); + virtual ~IsoSurface() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual double GetPotential (const Vector3d&, bool subtractThreshold, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual double GetPotential (const Vector3d&, bool subtractThreshold, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; - virtual void DispatchShutdownMessages(GenericMessenger& messenger); + virtual void DispatchShutdownMessages(GenericMessenger& messenger) override; protected: bool Function_Find_Root(ISO_ThreadData& itd, const Vector3d&, const Vector3d&, DBL*, DBL*, DBL& max_gradient, bool in_shadow_test, TraceThreadData* pThreadData); @@ -142,7 +156,7 @@ class IsoSurface : public ObjectBase private: - intrusive_ptr mginfo; // global, but just a statistic (read: not thread safe but we don't care) [trf] + boost::intrusive_ptr mginfo; // global, but just a statistic (read: not thread safe but we don't care) [trf] }; /// @} @@ -150,5 +164,6 @@ class IsoSurface : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_ISOSURFACE_H diff --git a/source/core/shape/lathe.cpp b/source/core/shape/lathe.cpp index ee023569f..9b009ae8b 100644 --- a/source/core/shape/lathe.cpp +++ b/source/core/shape/lathe.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -121,10 +121,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/lathe.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/bounding/boundingcylinder.h" #include "core/math/matrix.h" @@ -139,6 +146,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -280,9 +290,9 @@ bool Lathe::Intersect(const BasicRay& ray, IStack& Depth_Stack, TraceThreadData return false; // Intersect all cylindrical bounds. - vector& intervals = Thread->BCyl_Intervals; - vector& rint = Thread->BCyl_RInt; - vector& hint = Thread->BCyl_HInt; + std::vector& intervals = Thread->BCyl_Intervals; + std::vector& rint = Thread->BCyl_RInt; + std::vector& hint = Thread->BCyl_HInt; if((cnt = Intersect_BCyl(Spline->BCyl, intervals, rint, hint, P, D)) == 0) return false; @@ -1377,3 +1387,4 @@ void Lathe::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData } } +// end of namespace pov diff --git a/source/core/shape/lathe.h b/source/core/shape/lathe.h index 741ed9b63..180537e34 100644 --- a/source/core/shape/lathe.h +++ b/source/core/shape/lathe.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/bounding/boundingcylinder_fwd.h" #include "core/scene/object.h" namespace pov @@ -77,25 +86,21 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct BCyl_Struct BCYL; - -typedef struct Lathe_Struct LATHE; -typedef struct Lathe_Spline_Struct LATHE_SPLINE; -typedef struct Lathe_Spline_Entry_Struct LATHE_SPLINE_ENTRY; - -struct Lathe_Spline_Entry_Struct +struct Lathe_Spline_Entry_Struct final { Vector2d A, B, C, D; /* Coefficients of segment */ }; +using LATHE_SPLINE_ENTRY = Lathe_Spline_Entry_Struct; -struct Lathe_Spline_Struct +struct Lathe_Spline_Struct final { int References; /* Count references to this structure. */ LATHE_SPLINE_ENTRY *Entry; /* Array of spline segments. */ BCYL *BCyl; /* bounding cylinder. */ }; +using LATHE_SPLINE = Lathe_Spline_Struct; -class Lathe : public ObjectBase +class Lathe final : public ObjectBase { public: int Spline_Type; /* Spline type (linear, quadratic ...) */ @@ -105,19 +110,19 @@ class Lathe : public ObjectBase DBL Radius1, Radius2; /* Min./Max. radius */ Lathe(); - virtual ~Lathe(); + virtual ~Lathe() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Lathe(Vector2d *P, TraceThreadData *); protected: @@ -130,5 +135,6 @@ class Lathe : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_LATHE_H diff --git a/source/core/shape/lemon.cpp b/source/core/shape/lemon.cpp index 862c62755..e3355399b 100644 --- a/source/core/shape/lemon.cpp +++ b/source/core/shape/lemon.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,8 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/lemon.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/messenger.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" #include "core/render/ray.h" @@ -881,3 +887,4 @@ void Lemon::CalcUV(const Vector3d& IPoint, Vector2d& Result) const #endif // POV_ENABLE_LEMON_UV } +// end of namespace pov diff --git a/source/core/shape/lemon.h b/source/core/shape/lemon.h index ffd144ac7..42b882169 100644 --- a/source/core/shape/lemon.h +++ b/source/core/shape/lemon.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,15 +41,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/messenger_fwd.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/scene/object.h" -namespace pov_base -{ -class GenericMessenger; -class MessageContext; -}; - namespace pov { @@ -71,35 +73,35 @@ namespace pov /// //****************************************************************************** -class Lemon : public ObjectBase +class Lemon final : public ObjectBase { private: - struct LEMON_INT + struct LEMON_INT final { DBL d; /* Distance of intersection point */ Vector3d n;/* Normal */ }; public: Lemon(); - virtual ~Lemon(); + virtual ~Lemon() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; #ifdef POV_ENABLE_LEMON_UV /// @attention /// UV mapping of this primitive should not be enabled until the primary /// parameterization has been amended so that users have full control over the /// primitive's orientation, rather than just the axis of rotational symmetry. - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; #endif // POV_ENABLE_LEMON_UV - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Lemon_Data(GenericMessenger& messenger, const MessageContext& context); @@ -122,5 +124,6 @@ class Lemon : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_OVUS_H diff --git a/source/core/shape/mesh.cpp b/source/core/shape/mesh.cpp index f1ad19c4c..b8b7540d6 100644 --- a/source/core/shape/mesh.cpp +++ b/source/core/shape/mesh.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -60,11 +60,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/mesh.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/material/texture.h" #include "core/math/matrix.h" @@ -2448,3 +2454,4 @@ void Mesh::Determine_Textures(Intersection *isect, bool hitinside, WeightedTextu } } +// end of namespace pov diff --git a/source/core/shape/mesh.h b/source/core/shape/mesh.h index aaaa6e7e7..f6493e138 100644 --- a/source/core/shape/mesh.h +++ b/source/core/shape/mesh.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/bounding/boundingbox_fwd.h" #include "core/scene/object.h" namespace pov @@ -62,40 +71,18 @@ namespace pov /// //****************************************************************************** -typedef struct BBox_Tree_Struct BBOX_TREE; - /***************************************************************************** * Global typedefs ******************************************************************************/ -typedef struct Mesh_Data_Struct MESH_DATA; -typedef struct Mesh_Triangle_Struct MESH_TRIANGLE; - -typedef struct Hash_Table_Struct HASH_TABLE; -typedef struct UV_Hash_Table_Struct UV_HASH_TABLE; - // TODO - a SnglVector2d should probably suffice for MeshUVVector, and reduce the Mesh's memory footprint by 8 bytes per triangle. // TODO - on systems with 64-bit int type, int is probably overkill for MeshIndex; maybe we even want to make Mesh a template, using short for small meshes. -typedef SnglVector3d MeshVector; ///< Data type used to store vertices and normals. -typedef Vector2d MeshUVVector; ///< Data type used to store UV coordinates. -typedef signed int MeshIndex; ///< Data type used to store indices into vertices / normals / uv coordinate / texture tables. Must be signed and able to hold 2*max. +using MeshVector = SnglVector3d; ///< Data type used to store vertices and normals. +using MeshUVVector = Vector2d; ///< Data type used to store UV coordinates. +using MeshIndex = signed int; ///< Data type used to store indices into vertices / normals / uv coordinate / texture tables. Must be signed and able to hold 2*max. -struct Mesh_Data_Struct -{ - int References; ///< Number of references to the mesh. - MeshIndex Number_Of_UVCoords; ///< Number of UV coords in the mesh. - MeshIndex Number_Of_Normals; ///< Number of normals in the mesh. - MeshIndex Number_Of_Triangles; ///< Number of trinagles in the mesh. - MeshIndex Number_Of_Vertices; ///< Number of vertices in the mesh. - MeshVector *Normals, *Vertices; ///< Arrays of normals and vertices. - MeshUVVector *UVCoords; ///< Array of UV coordinates - MESH_TRIANGLE *Triangles; ///< Array of triangles. - BBOX_TREE *Tree; ///< Bounding box tree for mesh. - Vector3d Inside_Vect; ///< vector to use to test 'inside' -}; - -struct Mesh_Triangle_Struct +struct Mesh_Triangle_Struct final { MeshVector Perp; ///< Vector used for smooth triangles. @@ -113,22 +100,40 @@ struct Mesh_Triangle_Struct unsigned int vAxis:2; ///< Axis for smooth triangle. unsigned int ThreeTex:1; ///< Color Triangle Patch. }; +using MESH_TRIANGLE = Mesh_Triangle_Struct; ///< @deprecated + +struct Mesh_Data_Struct final +{ + int References; ///< Number of references to the mesh. + MeshIndex Number_Of_UVCoords; ///< Number of UV coords in the mesh. + MeshIndex Number_Of_Normals; ///< Number of normals in the mesh. + MeshIndex Number_Of_Triangles; ///< Number of trinagles in the mesh. + MeshIndex Number_Of_Vertices; ///< Number of vertices in the mesh. + MeshVector *Normals, *Vertices; ///< Arrays of normals and vertices. + MeshUVVector *UVCoords; ///< Array of UV coordinates + MESH_TRIANGLE *Triangles; ///< Array of triangles. + BBOX_TREE *Tree; ///< Bounding box tree for mesh. + Vector3d Inside_Vect; ///< vector to use to test 'inside' +}; +using MESH_DATA = Mesh_Data_Struct; ///< @deprecated -struct Hash_Table_Struct +struct Hash_Table_Struct final { MeshIndex Index; MeshVector P; - HASH_TABLE *Next; + Hash_Table_Struct *Next; }; +using HASH_TABLE = Hash_Table_Struct; ///< @deprecated -struct UV_Hash_Table_Struct +struct UV_Hash_Table_Struct final { MeshIndex Index; MeshUVVector P; - UV_HASH_TABLE *Next; + UV_Hash_Table_Struct *Next; }; +using UV_HASH_TABLE = UV_Hash_Table_Struct; ///< @deprecated -class Mesh : public ObjectBase +class Mesh final : public ObjectBase { public: MESH_DATA *Data; ///< Mesh data holding triangles. @@ -137,19 +142,19 @@ class Mesh : public ObjectBase bool has_inside_vector; Mesh(); - virtual ~Mesh(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual ~Mesh() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; virtual bool IsOpaque() const override; void Create_Mesh_Hash_Tables(); @@ -167,7 +172,7 @@ class Mesh : public ObjectBase MeshIndex Mesh_Hash_UV(MeshIndex *Number, MeshIndex *Max, MeshUVVector **Elements, const Vector2d& aPoint); void Smooth_Mesh_Normal(Vector3d& Result, const MESH_TRIANGLE *Triangle, const Vector3d& IPoint) const; - void Determine_Textures(Intersection *, bool, WeightedTextureVector&, TraceThreadData *); + virtual void Determine_Textures(Intersection *, bool, WeightedTextureVector&, TraceThreadData *) override; protected: bool Intersect(const BasicRay& ray, IStack& Depth_Stack, TraceThreadData *Thread); void Compute_Mesh_BBox(); @@ -196,5 +201,6 @@ class Mesh : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_MESH_H diff --git a/source/core/shape/ovus.cpp b/source/core/shape/ovus.cpp index 9edd1bb15..f42e461b5 100644 --- a/source/core/shape/ovus.cpp +++ b/source/core/shape/ovus.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -69,6 +69,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/ovus.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" #include "core/render/ray.h" @@ -986,3 +994,4 @@ void Ovus::CalcUV(const Vector3d& IPoint, Vector2d& Result) const } } +// end of namespace pov diff --git a/source/core/shape/ovus.h b/source/core/shape/ovus.h index 84bdfb3c5..b89663d91 100644 --- a/source/core/shape/ovus.h +++ b/source/core/shape/ovus.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,6 +41,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -64,24 +72,24 @@ namespace pov /// //****************************************************************************** -class Ovus : public ObjectBase +class Ovus final : public ObjectBase { public: Ovus(); - virtual ~Ovus(); + virtual ~Ovus() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; /// radius of bottom sphere (provided in SDL) DBL BottomRadius; @@ -117,5 +125,6 @@ class Ovus : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_OVUS_H diff --git a/source/core/shape/parametric.cpp b/source/core/shape/parametric.cpp index c72bd8dc7..065dd5c82 100644 --- a/source/core/shape/parametric.cpp +++ b/source/core/shape/parametric.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,9 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/parametric.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -49,6 +57,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -663,7 +674,7 @@ ObjectPtr Parametric::Copy() New->Trans = Copy_Transform(Trans); New->PData = Copy_PrecompParVal(); - New->container = shared_ptr(container->Copy()); + New->container = std::shared_ptr(container->Copy()); return (New); } @@ -728,7 +739,7 @@ Parametric::~Parametric() Parametric::Parametric() : NonsolidObject(PARAMETRIC_OBJECT) { - container = shared_ptr(new ContainedByBox()); + container = std::shared_ptr(new ContainedByBox()); Make_BBox(BBox, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0); @@ -1123,3 +1134,4 @@ void Parametric::Evaluate_Function_Interval_UV(GenericScalarFunctionInstance& fn } } +// end of namespace pov diff --git a/source/core/shape/parametric.h b/source/core/shape/parametric.h index 128383c84..b51186936 100644 --- a/source/core/shape/parametric.h +++ b/source/core/shape/parametric.h @@ -12,7 +12,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -43,6 +43,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/scene/object.h" @@ -72,18 +82,15 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct PrecompParValues_Struct PRECOMP_PAR_DATA; - -struct PrecompParValues_Struct +struct PrecompParValues_Struct final { int use, depth; char flags; DBL *Low[3], *Hi[3]; /* X,Y,Z */ }; +using PRECOMP_PAR_DATA = PrecompParValues_Struct; ///< @deprecated -class FPUContext; - -class Parametric : public NonsolidObject +class Parametric final : public NonsolidObject { public: @@ -92,22 +99,22 @@ class Parametric : public NonsolidObject DBL accuracy; DBL max_gradient; - shared_ptr container; + std::shared_ptr container; Parametric(); - virtual ~Parametric(); + virtual ~Parametric() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Precompute_Parametric_Values(char flags, int depth, TraceThreadData *Thread); protected: @@ -127,5 +134,6 @@ class Parametric : public NonsolidObject //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PARAMETRIC_H diff --git a/source/core/shape/plane.cpp b/source/core/shape/plane.cpp index bbbbef7ed..f1f3c2f03 100644 --- a/source/core/shape/plane.cpp +++ b/source/core/shape/plane.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/plane.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -623,3 +631,4 @@ bool Plane::Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3 } } +// end of namespace pov diff --git a/source/core/shape/plane.h b/source/core/shape/plane.h index 7e8098f6d..cc8de3041 100644 --- a/source/core/shape/plane.h +++ b/source/core/shape/plane.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,28 +70,28 @@ namespace pov /// //****************************************************************************** -class Plane : public ObjectBase +class Plane final : public ObjectBase { public: Vector3d Normal_Vector; DBL Distance; Plane(); - virtual ~Plane(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; // TODO FIXME - document that it uses the default (it does, right?) [trf] - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual ObjectPtr Invert(); - virtual void Compute_BBox(); - virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const; + virtual ~Plane() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; // TODO FIXME - document that it uses the default (it does, right?) [trf] + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual ObjectPtr Invert() override; + virtual void Compute_BBox() override; + virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; protected: bool Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) const; }; @@ -93,5 +101,6 @@ class Plane : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PLANE_H diff --git a/source/core/shape/polygon.cpp b/source/core/shape/polygon.cpp index aa7f04ebd..5aef6ba8e 100644 --- a/source/core/shape/polygon.cpp +++ b/source/core/shape/polygon.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -61,10 +61,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/polygon.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -974,3 +980,4 @@ bool Polygon::in_polygon(int number, Vector2d *points, DBL u, DBL v) } } +// end of namespace pov diff --git a/source/core/shape/polygon.h b/source/core/shape/polygon.h index 721aea12e..3252b0d9c 100644 --- a/source/core/shape/polygon.h +++ b/source/core/shape/polygon.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -67,35 +75,34 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct Polygon_Data_Struct POLYGON_DATA; - -struct Polygon_Data_Struct +struct Polygon_Data_Struct final { int References; int Number; Vector2d *Points; }; +using POLYGON_DATA = Polygon_Data_Struct; ///< @deprecated -class Polygon : public NonsolidObject +class Polygon final : public NonsolidObject { public: Vector3d S_Normal; POLYGON_DATA *Data; Polygon(); - virtual ~Polygon(); + virtual ~Polygon() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; // TODO FIXME - does this use the default mapping? [trf] - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; // TODO FIXME - does this use the default mapping? [trf] + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Polygon(int number, Vector3d *points); protected: @@ -108,5 +115,6 @@ class Polygon : public NonsolidObject //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_POLYGON_H diff --git a/source/core/shape/polynomial.cpp b/source/core/shape/polynomial.cpp index 83381e903..de466ca24 100644 --- a/source/core/shape/polynomial.cpp +++ b/source/core/shape/polynomial.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,6 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/polynomial.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" @@ -1504,3 +1512,4 @@ bool Poly::Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d } } +// end of namespace pov diff --git a/source/core/shape/polynomial.h b/source/core/shape/polynomial.h index 576f01a25..d4e9c61c7 100644 --- a/source/core/shape/polynomial.h +++ b/source/core/shape/polynomial.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -74,26 +82,26 @@ inline int term_counts(int x) { return ((x+1)*(x+2)*(x+3)/6); } * Global typedefs ******************************************************************************/ -class Poly : public ObjectBase +class Poly final : public ObjectBase { public: int Order; DBL *Coeffs; Poly(int order); - virtual ~Poly(); + virtual ~Poly() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); - virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; + virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; bool Set_Coeff(const unsigned int x,const unsigned int y, const unsigned int z, const DBL value); protected: @@ -113,5 +121,6 @@ class Poly : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_POLYNOMIAL_H diff --git a/source/core/shape/prism.cpp b/source/core/shape/prism.cpp index ff8a7a059..381a83200 100644 --- a/source/core/shape/prism.cpp +++ b/source/core/shape/prism.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -115,10 +115,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/prism.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" @@ -131,6 +137,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -1727,3 +1736,4 @@ void Prism::Compute_Prism(Vector2d *P, TraceThreadData *Thread) } } +// end of namespace pov diff --git a/source/core/shape/prism.h b/source/core/shape/prism.h index 88787994b..c134a40fa 100644 --- a/source/core/shape/prism.h +++ b/source/core/shape/prism.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -80,23 +88,22 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct Prism_Spline_Struct PRISM_SPLINE; -typedef struct Prism_Spline_Entry_Struct PRISM_SPLINE_ENTRY; - -struct Prism_Spline_Entry_Struct +struct Prism_Spline_Entry_Struct final { DBL x1, y1, x2, y2; /* Min./Max. coordinates of segment */ DBL v1, u2, v2; /* Min./Max. coordinates of segment in , u1 not needed */ Vector2d A, B, C, D; /* Coefficients of segment */ }; +using PRISM_SPLINE_ENTRY = Prism_Spline_Entry_Struct; ///< @deprecated -struct Prism_Spline_Struct +struct Prism_Spline_Struct final { int References; PRISM_SPLINE_ENTRY *Entry; }; +using PRISM_SPLINE = Prism_Spline_Struct; ///< @deprecated -class Prism : public ObjectBase +class Prism final : public ObjectBase { public: int Number; @@ -108,18 +115,18 @@ class Prism : public ObjectBase DBL u1, v1, u2, v2; /* Overall bounding rectangle of spline */ Prism(); - virtual ~Prism(); + virtual ~Prism() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Prism(Vector2d *P, TraceThreadData *Thread); protected: @@ -132,5 +139,6 @@ class Prism : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PRISM_H diff --git a/source/core/shape/quadric.cpp b/source/core/shape/quadric.cpp index e1b24a835..a2f1146e6 100644 --- a/source/core/shape/quadric.cpp +++ b/source/core/shape/quadric.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/quadric.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include + +// POV-Ray header files (base module) +// (none at the moment) +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -50,6 +59,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -760,7 +772,7 @@ void Quadric::Compute_BBox(Vector3d& ClipMin, Vector3d& ClipMax) if(!Clip.empty()) { /* Intersect the members bounding boxes. */ - for(vector::iterator it = Clip.begin(); it != Clip.end(); it++) + for(std::vector::iterator it = Clip.begin(); it != Clip.end(); it++) { ObjectPtr p = *it; if (Test_Flag(p, INVERTED_FLAG) == false) @@ -1474,3 +1486,4 @@ void Quadric::Compute_Plane_Min_Max(const Plane *plane, Vector3d& Min, Vector3d& } } +// end of namespace pov diff --git a/source/core/shape/quadric.h b/source/core/shape/quadric.h index 3ea92bacd..e26f438ef 100644 --- a/source/core/shape/quadric.h +++ b/source/core/shape/quadric.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/scene/object.h" @@ -65,7 +73,7 @@ class Plane; /// //****************************************************************************** -class Quadric : public ObjectBase +class Quadric final : public ObjectBase { public: Vector3d Square_Terms; @@ -75,19 +83,19 @@ class Quadric : public ObjectBase bool Automatic_Bounds; Quadric(); - virtual ~Quadric(); + virtual ~Quadric() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual ObjectPtr Invert(); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual ObjectPtr Invert() override; + virtual void Compute_BBox() override; static void Compute_Plane_Min_Max(const Plane *plane, Vector3d& Min, Vector3d& Max); void Compute_BBox(Vector3d& ClipMin, Vector3d& ClipMax); @@ -102,5 +110,6 @@ class Quadric : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_QUADRIC_H diff --git a/source/core/shape/sor.cpp b/source/core/shape/sor.cpp index ff74dee0b..3342ee951 100644 --- a/source/core/shape/sor.cpp +++ b/source/core/shape/sor.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -98,10 +98,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/sor.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/bounding/boundingcylinder.h" #include "core/math/matrix.h" @@ -115,6 +122,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -336,9 +346,9 @@ bool Sor::Intersect(const BasicRay& ray, IStack& Depth_Stack, TraceThreadData *T } /* Intersect all cylindrical bounds. */ - vector& intervals = Thread->BCyl_Intervals; - vector& rint = Thread->BCyl_RInt; - vector& hint = Thread->BCyl_HInt; + std::vector& intervals = Thread->BCyl_Intervals; + std::vector& rint = Thread->BCyl_RInt; + std::vector& hint = Thread->BCyl_HInt; if ((cnt = Intersect_BCyl(Spline->BCyl, intervals, rint, hint, P, D)) == 0) { @@ -1302,3 +1312,4 @@ void Sor::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData * } } +// end of namespace pov diff --git a/source/core/shape/sor.h b/source/core/shape/sor.h index 856f6f9a9..794c39d95 100644 --- a/source/core/shape/sor.h +++ b/source/core/shape/sor.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/bounding/boundingcylinder_fwd.h" #include "core/scene/object.h" namespace pov @@ -72,24 +81,21 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct BCyl_Struct BCYL; - -typedef struct Sor_Spline_Entry_Struct SOR_SPLINE_ENTRY; -typedef struct Sor_Spline_Struct SOR_SPLINE; - -struct Sor_Spline_Entry_Struct +struct Sor_Spline_Entry_Struct final { DBL A, B, C, D; }; +using SOR_SPLINE_ENTRY = Sor_Spline_Entry_Struct; ///< @deprecated -struct Sor_Spline_Struct +struct Sor_Spline_Struct final { int References; SOR_SPLINE_ENTRY *Entry; BCYL *BCyl; /* bounding cylinder. */ }; +using SOR_SPLINE = Sor_Spline_Struct; ///< @deprecated -class Sor : public ObjectBase +class Sor final : public ObjectBase { public: int Number; @@ -100,19 +106,19 @@ class Sor : public ObjectBase DBL Cap_Radius_Squared; /* Radius**2 of the cap plane */ Sor(); - virtual ~Sor(); + virtual ~Sor() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Sor(Vector2d *P, TraceThreadData *Thread); protected: @@ -125,5 +131,6 @@ class Sor : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SOR_H diff --git a/source/core/shape/sphere.cpp b/source/core/shape/sphere.cpp index 9a61b90a6..e79e01fdb 100644 --- a/source/core/shape/sphere.cpp +++ b/source/core/shape/sphere.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/sphere.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -604,48 +612,6 @@ void Sphere::Transform(const TRANSFORM *tr) -/***************************************************************************** -* -* FUNCTION -* -* Destroy_Sphere -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* ? -* -* DESCRIPTION -* -* - -* -* CHANGES -* -* - -* -******************************************************************************/ - -Sphere::~Sphere() -{ -#if(DUMP_OBJECT_DATA == 1) - Debug_Info("{ // SPHERE \n"); - DUMP_OBJECT_FIELDS(this); - Debug_Info("\t{ %f, %f, %f }, // Center\n", \ - (DBL)Center[X], \ - (DBL)Center[Y], \ - (DBL)Center[Z]); \ - Debug_Info("\t%f // Radius\n", (DBL)Radius); - Debug_Info("}\n"); -#endif -} - - - /***************************************************************************** * * FUNCTION @@ -789,3 +755,4 @@ bool Sphere::Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector } } +// end of namespace pov diff --git a/source/core/shape/sphere.h b/source/core/shape/sphere.h index b523ab64a..088f83115 100644 --- a/source/core/shape/sphere.h +++ b/source/core/shape/sphere.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,27 +70,26 @@ namespace pov /// //****************************************************************************** -class Sphere : public ObjectBase +class Sphere final : public ObjectBase { public: Vector3d Center; DBL Radius; Sphere(); - virtual ~Sphere(); - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); - virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; + virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; static bool Intersect(const BasicRay& ray, const Vector3d& Center, DBL Radius2, DBL *Depth1, DBL *Depth2); @@ -108,5 +115,6 @@ class Sphere : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SPHERE_H diff --git a/source/core/shape/spheresweep.cpp b/source/core/shape/spheresweep.cpp index 9ff0d791b..13d6d1412 100644 --- a/source/core/shape/spheresweep.cpp +++ b/source/core/shape/spheresweep.cpp @@ -13,7 +13,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -81,8 +81,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/spheresweep.h" +// C++ variants of C standard header files +#include + +// C++ standard header files #include +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" @@ -224,7 +232,7 @@ bool SphereSweep::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceTh if(Num_Isect > 0) { // Sort intersections - QSORT(reinterpret_cast(Isect), Num_Isect, sizeof(SPHSWEEP_INT), Comp_Isects); + std::qsort(Isect, Num_Isect, sizeof(SPHSWEEP_INT), Comp_Isects); // Delete invalid intersections inside the sphere sweep Num_Isect = Find_Valid_Points(Isect, Num_Isect, New_Ray); @@ -1817,3 +1825,4 @@ int SphereSweep::bezier_01(int degree, const DBL* Coef, DBL* Roots, bool sturm, } } +// end of namespace pov diff --git a/source/core/shape/spheresweep.h b/source/core/shape/spheresweep.h index 33b6faaa0..00a23abd9 100644 --- a/source/core/shape/spheresweep.h +++ b/source/core/shape/spheresweep.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,6 +41,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -83,19 +91,16 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct Sphere_Sweep_Sphere_Struct SPHSWEEP_SPH; -typedef struct Sphere_Sweep_Segment_Struct SPHSWEEP_SEG; -typedef struct Sphere_Sweep_Intersection_Structure SPHSWEEP_INT; - /* Single sphere, used to connect two adjacent segments */ -struct Sphere_Sweep_Sphere_Struct +struct Sphere_Sweep_Sphere_Struct final { Vector3d Center; DBL Radius; }; +using SPHSWEEP_SPH = Sphere_Sweep_Sphere_Struct; ///< @deprecated /* One segment of the sphere sweep */ -struct Sphere_Sweep_Segment_Struct +struct Sphere_Sweep_Segment_Struct final { SPHSWEEP_SPH Closing_Sphere[2]; /* Spheres closing the segment */ Vector3d Center_Deriv[2]; /* Derivatives of center funcs for 0 and 1 */ @@ -104,17 +109,19 @@ struct Sphere_Sweep_Segment_Struct Vector3d Center_Coef[SPH_SWP_MAX_COEFS]; /* Coefs of center polynomial */ DBL Radius_Coef[SPH_SWP_MAX_COEFS]; /* Coefs of radius polynomial */ }; +using SPHSWEEP_SEG = Sphere_Sweep_Segment_Struct; ///< @deprecated // Temporary storage for intersection values -struct Sphere_Sweep_Intersection_Structure +struct Sphere_Sweep_Intersection_Structure final { DBL t; // Distance along ray Vector3d Point; // Intersection point Vector3d Normal; // Normal at intersection point }; +using SPHSWEEP_INT = Sphere_Sweep_Intersection_Structure; ///< @deprecated /* The complete object */ -class SphereSweep : public ObjectBase +class SphereSweep final : public ObjectBase { public: int Interpolation; @@ -127,18 +134,18 @@ class SphereSweep : public ObjectBase DBL Depth_Tolerance; /* Preferred depth tolerance */ SphereSweep(); - virtual ~SphereSweep(); + virtual ~SphereSweep() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute(); protected: @@ -177,5 +184,6 @@ class SphereSweep : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SPHERESWEEP_H diff --git a/source/core/shape/superellipsoid.cpp b/source/core/shape/superellipsoid.cpp index 6563ca0a9..d1d94ddc2 100644 --- a/source/core/shape/superellipsoid.cpp +++ b/source/core/shape/superellipsoid.cpp @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -66,6 +66,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/superellipsoid.h" +// C++ variants of C standard header files +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -1294,7 +1304,7 @@ int Superellipsoid::find_ray_plane_points(const Vector3d& P, const Vector3d& D, /* Sort the results for further processing. */ - QSORT(reinterpret_cast(dists), cnt, sizeof(DBL), compdists); + std::qsort(dists, cnt, sizeof(DBL), compdists); return(cnt); } @@ -1548,3 +1558,4 @@ bool Superellipsoid::check_hit2(const Vector3d& P, const Vector3d& D, DBL t0, Ve } } +// end of namespace pov diff --git a/source/core/shape/superellipsoid.h b/source/core/shape/superellipsoid.h index 927b81de8..2dc25fad1 100644 --- a/source/core/shape/superellipsoid.h +++ b/source/core/shape/superellipsoid.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,24 +70,24 @@ namespace pov /// //****************************************************************************** -class Superellipsoid : public ObjectBase +class Superellipsoid final : public ObjectBase { public: Vector3d Power; Superellipsoid(); - virtual ~Superellipsoid(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual ~Superellipsoid() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; protected: bool Intersect(const BasicRay& ray, IStack& Depth_Stack, TraceThreadData *Thread); static bool intersect_box(const Vector3d& P, const Vector3d& D, DBL *dmin, DBL *dmax); @@ -98,5 +106,6 @@ class Superellipsoid : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SUPERELLIPSOID_H diff --git a/source/core/shape/torus.cpp b/source/core/shape/torus.cpp index c2943a04d..4a084ee88 100644 --- a/source/core/shape/torus.cpp +++ b/source/core/shape/torus.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -48,6 +48,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/torus.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" @@ -1131,3 +1139,4 @@ void Torus::CalcUV(const Vector3d& IPoint, Vector2d& Result) const } } +// end of namespace pov diff --git a/source/core/shape/torus.h b/source/core/shape/torus.h index fbb11f198..8d60b93be 100644 --- a/source/core/shape/torus.h +++ b/source/core/shape/torus.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -72,19 +80,19 @@ class Torus : public ObjectBase DBL MajorRadius, MinorRadius; Torus(); - virtual ~Torus(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual ~Torus() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; protected: int Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) const; bool Test_Thick_Cylinder(const Vector3d& P, const Vector3d& D, DBL h1, DBL h2, DBL r1, DBL r2) const; @@ -92,7 +100,7 @@ class Torus : public ObjectBase }; /// @todo This class may need its own UVCoord() function. -class SpindleTorus : public Torus +class SpindleTorus final : public Torus { protected: @@ -124,15 +132,15 @@ class SpindleTorus : public Torus SpindleMode mSpindleMode; SpindleTorus(); - virtual ~SpindleTorus(); + virtual ~SpindleTorus() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool Precompute(); - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Compute_BBox(); + virtual bool Precompute() override; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Compute_BBox() override; protected: @@ -144,5 +152,6 @@ class SpindleTorus : public Torus //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TORUS_H diff --git a/source/core/shape/triangle.cpp b/source/core/shape/triangle.cpp index e06b0a5bc..be771c7a2 100644 --- a/source/core/shape/triangle.cpp +++ b/source/core/shape/triangle.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,10 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/triangle.h" -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) #include "base/mathutil.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -1417,3 +1421,4 @@ bool Triangle::Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVect } } +// end of namespace pov diff --git a/source/core/shape/triangle.h b/source/core/shape/triangle.h index d68ce71f8..0f633fed0 100644 --- a/source/core/shape/triangle.h +++ b/source/core/shape/triangle.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -75,20 +83,20 @@ class Triangle : public NonsolidObject Triangle(); Triangle(int t); - virtual ~Triangle(); + virtual ~Triangle() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; // TODO FIXME - why is there no UV-mapping for this trivial object? [trf] - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); - virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; // TODO FIXME - why is there no UV-mapping for this trivial object? [trf] + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; + virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; virtual bool Compute_Triangle(); protected: @@ -96,22 +104,22 @@ class Triangle : public NonsolidObject void find_triangle_dominant_axis(); }; -class SmoothTriangle : public Triangle +class SmoothTriangle final : public Triangle { public: Vector3d N1, N2, N3, Perp; SmoothTriangle(); - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; - virtual bool Compute_Triangle(); + virtual bool Compute_Triangle() override; static DBL Calculate_Smooth_T(const Vector3d& IPoint, const Vector3d& P1, const Vector3d& P2, const Vector3d& P3); protected: @@ -123,5 +131,6 @@ class SmoothTriangle : public Triangle //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TRIANGLE_H diff --git a/source/core/shape/truetype.cpp b/source/core/shape/truetype.cpp index fec71e1c2..bd225c33c 100644 --- a/source/core/shape/truetype.cpp +++ b/source/core/shape/truetype.cpp @@ -38,11 +38,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/truetype.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include +// POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/povassert.h" +#include "base/stringutilities.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -55,6 +63,8 @@ namespace pov { +using namespace pov_base; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -126,32 +136,32 @@ typedef int Fixed; using GlyphIndex = POV_UINT32; -typedef struct +struct sfnt_OffsetTable final { Fixed version; /* 0x10000 (1.0) */ USHORT numTables; /* number of tables */ USHORT searchRange; /* (max2 <= numTables)*16 */ USHORT entrySelector; /* log2 (max2 <= numTables) */ USHORT rangeShift; /* numTables*16-searchRange */ -} sfnt_OffsetTable; +}; -typedef struct +struct sfnt_TableDirectory final { BYTE tag[4]; ULONG checkSum; ULONG offset; ULONG length; -} sfnt_TableDirectory; +}; typedef sfnt_TableDirectory *sfnt_TableDirectoryPtr; -typedef struct +struct longDateTime final { ULONG bc; ULONG ad; -} longDateTime; +}; -typedef struct +struct sfnt_FontHeader final { Fixed version; /* for this table, set to 1.0 */ Fixed fontRevision; /* For Font Manufacturer */ @@ -174,25 +184,25 @@ typedef struct SHORT fontDirectionHint; SHORT indexToLocFormat; /* 0 - short offsets, 1 - long offsets */ SHORT glyphDataFormat; -} sfnt_FontHeader; +}; -typedef struct +struct sfnt_platformEntry final { USHORT platformID; USHORT specificID; ULONG offset; -} sfnt_platformEntry; +}; typedef sfnt_platformEntry *sfnt_platformEntryPtr; -typedef struct +struct sfnt_mappingTable final { USHORT format; USHORT length; USHORT language; -} sfnt_mappingTable; +}; -typedef struct +struct sfnt_HorizHeader final { Fixed version; @@ -215,9 +225,9 @@ typedef struct SHORT metricDataFormat; USHORT numberOfHMetrics; /* number of hMetrics in the hmtx table */ -} sfnt_HorizHeader; +}; -struct GlyphHeader +struct GlyphHeader final { SHORT numContours; SHORT xMin; @@ -227,7 +237,7 @@ struct GlyphHeader GlyphHeader() : numContours(0), xMin(0), yMin(0), xMax(0), yMax(0) {} }; -struct GlyphOutline +struct GlyphOutline final { GlyphHeader header; std::vector endPoints; @@ -240,17 +250,17 @@ struct GlyphOutline {} }; -typedef struct +struct Contour final { BYTE inside_flag; /* 1 if this an inside contour, 0 if outside */ USHORT count; /* Number of points in the contour */ - vector flags; /* On/off curve flags */ - vector x, y; /* Coordinates of control vertices */ -} Contour; + std::vector flags; /* On/off curve flags */ + std::vector x, y; /* Coordinates of control vertices */ +}; /* Contour information for a single glyph */ -struct GlyphStruct +struct GlyphStruct final { GlyphHeader header; /* Count and sizing information about this glyph */ GlyphIndex glyph_index; /* Internal glyph index for this character */ @@ -259,40 +269,40 @@ struct GlyphStruct GlyphIndex myMetrics; /* Which glyph index this is for metrics */ }; -typedef struct KernData_struct +struct KernData final { USHORT left, right; /* Glyph index of left/right to kern */ FWord value; /* Delta in FUnits to apply in between */ -} KernData; +}; /* * [esp] There's already a "KernTable" on the Mac... renamed to TTKernTable for * now in memoriam to its author. */ -typedef struct KernStruct +struct TTKernTable final { USHORT coverage; /* Coverage bit field of this subtable */ USHORT nPairs; /* # of kerning pairs in this table */ KernData *kern_pairs; /* Array of kerning values */ -} TTKernTable; +}; -typedef struct KernTableStruct +struct KernTables final { USHORT nTables; /* # of subtables in the kerning table */ TTKernTable *tables; -} KernTables; +}; -typedef struct longHorMertric +struct longHorMetric final { uFWord advanceWidth; /* Total width of a glyph in FUnits */ FWord lsb; /* FUnits to the left of the glyph */ -} longHorMetric; +}; typedef std::map GlyphPtrMap; -struct CMAPSelector +struct CMAPSelector final { CMAPSelector() = default; CMAPSelector(USHORT pid, USHORT sid, CharsetID cs); @@ -310,7 +320,7 @@ struct CMAPInfo using CMAPInfoPtr = CMAPInfo*; -struct CMAP4Info : public CMAPInfo +struct CMAP4Info final : public CMAPInfo { CMAP4Info(); virtual ~CMAP4Info() override; @@ -322,7 +332,7 @@ struct CMAP4Info : public CMAPInfo *idDelta, *idRangeOffset; }; -struct TrueTypeInfo +struct TrueTypeInfo final { TrueTypeInfo(); ~TrueTypeInfo(); @@ -339,7 +349,7 @@ struct TrueTypeInfo KernTables kerning_tables; /* Kerning info for this font */ USHORT numberOfHMetrics; /* The number of explicit spacings */ longHorMetric *hmtx_table; /* Horizontal spacing info */ - vector cmapInfo; + std::vector cmapInfo; }; /***************************************************************************** @@ -3078,7 +3088,7 @@ void TrueType::Compute_BBox() } -TrueTypeFont::TrueTypeFont(const UCS2String& fn, const shared_ptr& f, +TrueTypeFont::TrueTypeFont(const UCS2String& fn, const std::shared_ptr& f, POV_UINT32 cm, CharsetID cs, LegacyCharset scs) : filename(fn), file(f), @@ -3179,4 +3189,4 @@ TrueTypeInfo::~TrueTypeInfo() } } - +// end of namespace pov diff --git a/source/core/shape/truetype.h b/source/core/shape/truetype.h index d2dbc7f1e..4fdd19b86 100644 --- a/source/core/shape/truetype.h +++ b/source/core/shape/truetype.h @@ -39,14 +39,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "core/scene/object.h" +// C++ variants of C standard header files +// (none at the moment) -namespace pov_base -{ +// C++ standard header files +#include -class IStream; +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" -} +// POV-Ray header files (core module) +#include "core/scene/object.h" +#include "core/shape/csg_fwd.h" namespace pov { @@ -57,10 +61,6 @@ namespace pov /// /// @{ -class CSG; - -using pov_base::IStream; - //****************************************************************************** /// /// @name Object Types @@ -78,44 +78,45 @@ using pov_base::IStream; * Global typedefs ******************************************************************************/ -typedef struct GlyphStruct *GlyphPtr; +struct GlyphStruct; +using GlyphPtr = GlyphStruct*; struct TrueTypeInfo; -struct TrueTypeFont +struct TrueTypeFont final { static constexpr POV_UINT32 kAnyCMAP = 0xFFFFFFFFu; - TrueTypeFont(const UCS2String& fn, const shared_ptr& f, POV_UINT32 cm, CharsetID cs, LegacyCharset scs); + TrueTypeFont(const UCS2String& fn, const std::shared_ptr& f, POV_UINT32 cm, CharsetID cs, LegacyCharset scs); ~TrueTypeFont(); UCS2String filename; - shared_ptr file; + std::shared_ptr file; POV_UINT32 cmap; CharsetID charset; LegacyCharset legacyCharset; TrueTypeInfo* info; }; -class TrueType : public ObjectBase +class TrueType final : public ObjectBase { public: GlyphPtr glyph; /* (GlyphPtr) Pointer to the glyph */ DBL depth; /* Amount of extrusion */ TrueType(); - virtual ~TrueType(); + virtual ~TrueType() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; static void ProcessNewTTF(CSG *Object, TrueTypeFont* font, const UCS2 *text_string, DBL depth, const Vector3d& offset); protected: @@ -130,5 +131,6 @@ class TrueType : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TRUETYPE_H diff --git a/source/core/support/imageutil.cpp b/source/core/support/imageutil.cpp index d4fa117f0..ae50e194e 100644 --- a/source/core/support/imageutil.cpp +++ b/source/core/support/imageutil.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,10 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/support/imageutil.h" -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/povassert.h" +#include "base/image/encoding.h" +#include "base/image/image.h" +// POV-Ray header files (core module) #include "core/colour/spectral.h" #include "core/material/normal.h" #include "core/material/pattern.h" @@ -1398,5 +1405,5 @@ ImageData::~ImageData() delete data; } - } +// end of namespace pov diff --git a/source/core/support/imageutil.h b/source/core/support/imageutil.h index 2e557a378..b4bf41bc2 100644 --- a/source/core/support/imageutil.h +++ b/source/core/support/imageutil.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,17 +40,21 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) +#include "base/image/image_fwd.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" +#include "core/material/pattern_fwd.h" #include "core/math/vector.h" namespace pov { -class ImageData; -struct ImagePattern; - //############################################################################## /// /// @defgroup PovCoreSupportImageUtil Image Handling Utilities @@ -97,7 +101,7 @@ enum USE_ALPHA = 3 }; -class ImageData +class ImageData final { public: int References; // Keeps track of number of pointers to this structure @@ -145,5 +149,6 @@ void Destroy_Image(ImageData *image); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_IMAGEUTIL_H diff --git a/source/core/support/octree.cpp b/source/core/support/octree.cpp index 797b1533d..c78cd673c 100644 --- a/source/core/support/octree.cpp +++ b/source/core/support/octree.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,7 +41,7 @@ * To understand the relationship between an ot_id (x,y,z,size) and * a place in model space, you have to scale the integer values: * The nominal space occupied is given as follows: -* fsize = pow(2,size-127); +* fsize = pow(2,size-Pow2Bias); * lox = (float)x *fsize; loy = (float)y * fsize; loz = (float)z * fsize; * hix = lox + fsize; hiy = loy + fsize; hiz = loz + fsize; * All elements within this node are guaranteed to stick outside of the @@ -57,15 +57,22 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/support/octree.h" +// C++ variants of C standard header files #include -#include +#include +#include +// C++ standard header files #include +#include +// POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/mathutil.h" #include "base/pov_err.h" +#include "base/pov_mem.h" +// POV-Ray header files (core module) #include "core/colour/spectral.h" // this must be the last file included @@ -81,117 +88,372 @@ namespace pov #define SAFE_METHOD 1 // #define OT_DEBUG 1 -// WARNING: The default uses POV-Ray's own tricks which only work if -// "float" is a 32 bit IEEE 754 floating point number! If your platform -// does not use 32 bit IEEE 754 floating point numbers, radiosity will -// be broken!!! If you have this problem, your only other choice is to -// use an ISO C99 standard revision compatible compiler and library: -// -// Define this to 1 to use ISO C99 functions logbf and copysign. -// Define this to 2 to use ISO C99 functions ilogbf and copysign. -// Define this to 3 to use ISO C99 functions logb and copysign. -// Define this to 4 to use ISO C99 functions ilogb and copysign. -// -// You may want to try 1 to 4 as it cannot be generally said which one -// will be faster, but it is most likely that either 1 or 2 will perform -// slightly less well than POV-Ray's trick. In any case, testing all -// variants (0, 1 to 4) is recommended if possible on your platform! -// -// NOTE: Of course you should put the define for C99_COMPATIBLE_RADIOSITY -// into config.h and *not* mess around with this file!!! -#ifndef C99_COMPATIBLE_RADIOSITY -#define C99_COMPATIBLE_RADIOSITY 0 -#endif +//****************************************************************************** // compiler / target platform sanity checks // (note that these don't necessarily catch all possible quirks; they should be quite reliable though) -#if(C99_COMPATIBLE_RADIOSITY == 0) - #if( (INT_MAX != SIGNED32_MAX) || (INT_MIN + SIGNED32_MAX != -1) ) - #error "'int' is not 32 bit or does not use two's complement encoding; try a different C99_COMPATIBLE_RADIOSITY setting in config.h" - #endif - #if(FLT_RADIX != 2) - #error "'float' does not conform to IEEE 754 single-precision format; try a different C99_COMPATIBLE_RADIOSITY setting in config.h" - #endif - #if(FLT_MANT_DIG != 24) - #error "'float' does not conform to IEEE 754 single-precision format; try a different C99_COMPATIBLE_RADIOSITY setting in config.h" - #endif - #if(FLT_MAX_EXP != 128) - #error "'float' does not conform to IEEE 754 single-precision format; try a different C99_COMPATIBLE_RADIOSITY setting in config.h" - #endif - #if(FLT_MIN_EXP != -125) - #error "'float' does not conform to IEEE 754 single-precision format; try a different C99_COMPATIBLE_RADIOSITY setting in config.h" - #endif -#else - #if(FLT_RADIX != 2) - // logb family of functions will not work as expected - #error "floating point arithmetic uses an uncommon radix; this file will not compile on your machine" - #endif +#if (POV_PORTABLE_RADIOSITY == 0) + +// Needs IEEE 754 binary32 (aka single precision) floating-point format +// and an unpadded integer of same size. + +// According to the C++11 standard `std::uint32_t` must be exactly 32 bits wide, +// unpadded and unsigned, _or_ be undefined if the platform does not support +// such a type. In the latter case, we expect a compile error here complaining +// about `std::uint32_t`. +// If that's what you are seeing, do _not_ try to substitute a different type, +// as it is unlikely to work. Instead, try a different setting for +// POV_PORTABLE_RADIOSITY. + +static_assert( + (sizeof(float) == sizeof(std::uint32_t)) && + (std::numeric_limits::radix == 2) && + (std::numeric_limits::digits == 24) && + (std::numeric_limits::min_exponent == -125) && + (std::numeric_limits::max_exponent == 128), + "POV_PORTABLE_RADIOSITY setting 0 requires 'float' to conform to IEEE 754 binary32 " + "(aka single precision) format, which it doesn't. Try a different setting." + ); + +#elif (POV_PORTABLE_RADIOSITY == 5) + +// Needs IEEE 754 binary64 (aka double precision) floating-point format +// and an unpadded integer of same size. + +// According to the C++11 standard `std::uint64_t` must be exactly 32 bits wide, +// unpadded and unsigned, _or_ be undefined if the platform does not support +// such a type. In the latter case, we expect a compile error here complaining +// about `std::uint64_t`. +// If that's what you are seeing, do _not_ try to substitute a different type, +// as it is unlikely to work. Instead, try a different setting for +// POV_PORTABLE_RADIOSITY. + +static_assert( + (sizeof(double) == sizeof(std::uint64_t)) && + (std::numeric_limits::radix == 2) && + (std::numeric_limits::digits == 53) && + (std::numeric_limits::min_exponent == -1021) && + (std::numeric_limits::max_exponent == 1024), + "POV_PORTABLE_RADIOSITY setting 5 requires 'double' to conform to IEEE 754 binary64 " + "(aka double precision) format, which it doesn't. Try a different setting." + ); + +#elif (POV_PORTABLE_RADIOSITY == 1) || (POV_PORTABLE_RADIOSITY == 2) || (POV_PORTABLE_RADIOSITY == 7) + +// Needs Radix-2 floating-point format. + +static_assert( + (std::numeric_limits::radix == 2), + "POV_PORTABLE_RADIOSITY settings 1, 2 and 7 require 'float' to be a radix-2 type, " + "which it isn't. Try a different setting." + ); + +#elif (POV_PORTABLE_RADIOSITY == 3) || (POV_PORTABLE_RADIOSITY == 4) || (POV_PORTABLE_RADIOSITY == 9) + +// Needs Radix-2 floating-point format. + +static_assert( + (std::numeric_limits::radix == 2), + "POV_PORTABLE_RADIOSITY settings 3, 4 and 9 requires 'double' to be a radix-2 type, " + "which it isn't. Try a different setting." + ); + #endif -#if(C99_COMPATIBLE_RADIOSITY == 0) - // hacks exploiting IEEE standard float encoding properties - #define POW2OP_DECLARE() \ - union { float f; int l; } nodesize_hack; // MUST be float, NOT DBL - // This hex operation does a floor to next lower power of 2, by clearing - // all of the mantissa bits. Works only on IEEE single precision floats - #define POW2OP_FLOOR(dest,src) \ - nodesize_hack.f = (float)(src); \ - nodesize_hack.l &= 0xff800000; \ - (dest) = (DBL)nodesize_hack.f; - // This magic hex operation extracts the exponent, which gives us an - // integer number suitable for labelling a range of a power of 2. In IEEE - // format, value = pow(2,exponent-127). Therefore, if our index is, say, - // 129, then the item has a maximum extent of (2 to the (129-127)), or - // about 4 space units. - #define POW2OP_ENCODE(dest,src) \ - nodesize_hack.f = (float) (src); \ - (dest) = (nodesize_hack.l & 0x7f800000) >> 23; - #define POW2OP_DECODE(dest,src) \ - nodesize_hack.l = (src) << 23; \ - (dest) = (DBL) (size).f; -#elif(C99_COMPATIBLE_RADIOSITY == 1) - #define POW2OP_DECLARE() // nothing - #define POW2OP_FLOOR(dest,src) \ - (dest) = pow(2.0, logbf(src)); \ - (dest) = copysign((dest), (src)); - #define POW2OP_ENCODE(dest,src) \ - (dest) = ((int)logbf(src)) + 127; - #define POW2OP_DECODE(dest,src) \ - if( (src) >= 127 ) (dest) = (DBL)(1 << ((src) - 127)); \ - else (dest) = 1.0 / (DBL)(1 << (127 - (src))); -#elif(C99_COMPATIBLE_RADIOSITY == 2) - #define POW2OP_DECLARE() // nothing - #define POW2OP_FLOOR(dest,src) \ - (dest) = (DBL)(1 << ilogbf(src)); \ - (dest) = copysign((dest), (src)); - #define POW2OP_ENCODE(dest,src) \ - (dest) = ilogbf(src) + 127; - #define POW2OP_DECODE(dest,src) \ - if( (src) >= 127 ) (dest) = (DBL)(1 << ((src) - 127)); \ - else (dest) = 1.0 / (DBL)(1 << (127 - (src))); -#elif(C99_COMPATIBLE_RADIOSITY == 3) - #define POW2OP_DECLARE() // nothing - #define POW2OP_FLOOR(dest,src) \ - (dest) = pow(2.0, logb(src)); \ - (dest) = copysign((dest), (src)); - #define POW2OP_ENCODE(dest,src) \ - (dest) = ((int)logb(src)) + 127; - #define POW2OP_DECODE(dest,src) \ - if( (src) >= 127 ) (dest) = (DBL)(1 << ((src) - 127)); \ - else (dest) = 1.0 / (DBL)(1 << (127 - (src))); +//------------------------------------------------------------------------------ + +#if (POV_PORTABLE_RADIOSITY == 0) + +/// Bias inherent in @ref BiasedLog2() and @ref BiasedPow2(). +static constexpr auto Pow2Bias = 127; + +union FloatHack { float f; std::uint32_t i; }; + +/// Round down to power of 2. +/// +/// This function rounds a value down to a power of 2: +/// +/// @f[ +/// f(a) = 2 ^{ \left \lfloor log_2 a \right \rfloor } +/// @f] +/// +/// @note +/// The function signature may differ depending on +/// @ref POV_PORTABLE_RADIOSITY. +/// +/// @pre +/// The parameter value shall be finite and positive. +/// +static inline float Pow2Floor(float a) +{ + FloatHack hack; + hack.f = a; + // Directly clear all mantissa bits (= 1.0) + // while leaving sign and exponent intact. + hack.i &= 0xFF800000; + return hack.f; +} + +/// Compute biased integer base 2 logarithm. +/// +/// This function computes the integer part of the base 2 logarithm of the +/// parameter's magnitude, plus a constant bias: +/// +/// @f[ +/// f(a) = \left \lfloor log_2 \left | a \right | \right \rfloor + b +/// @f] +/// +/// The value of the bias _b_ depends on @ref POV_PORTABLE_RADIOSITY, bit is +/// the same value as used by @BiasedIntPow2(). +/// +/// @note +/// The function signature may differ depending on +/// @ref POV_PORTABLE_RADIOSITY. +/// +/// @pre +/// The parameter value shall be finite and positive. +/// +static inline int BiasedIntLog2(float a) +{ + FloatHack hack; + hack.f = a; + // Directly extract the (biased) float exponent as the final result. + return (hack.i & 0x7F800000u) >> 23; +} + +/// Compute biased integer power of 2. +/// +/// This function computes 2 raised to the power of the integer parameter +/// minus a constant bias: +/// +/// @f[ +/// f(a) = 2 ^{ a - b } +/// @f] +/// +/// The value of the bias _b_ depends on @ref POV_PORTABLE_RADIOSITY, bit is +/// the same value as used by @BiasedIntLog2(). +/// +/// @note +/// The function signature may differ depending on +/// @ref POV_PORTABLE_BIASEDINTPOW2. +/// +static inline float BiasedIntPow2(int a) +{ + FloatHack hack; + // Directly copy `a` into the (biased) float exponent, + // while clearing sign and mantissa bits (= positive, 1.0). + hack.i = uint32_t(a) << 23; + return hack.f; +} + +#elif (POV_PORTABLE_RADIOSITY == 1) + +static constexpr auto Pow2Bias = 0; + +static inline float Pow2Floor(float a) +{ + return std::powf(2.0f, std::logbf(a)); +} + +static inline int BiasedIntLog2(float a) +{ + return (int)std::logbf(a); +} + +static inline float BiasedIntPow2(int a) +{ + if (a >= 0) + return float(1 << a); + else + return 1.0f / float(1 << -a); +} + +#elif (POV_PORTABLE_RADIOSITY == 2) + +static constexpr auto Pow2Bias = 0; + +static inline float Pow2Floor(float a) +{ + return float(1 << std::ilogbf(a)); +} + +static inline int BiasedIntLog2(float a) +{ + return std::ilogbf(a); +} + +static inline float BiasedIntPow2(int a) +{ + if (a >= 0) + return float(1 << a); + else + return 1.0f / float(1 << -a); +} + +#elif (POV_PORTABLE_RADIOSITY == 3) + +static constexpr auto Pow2Bias = 0; + +static inline double Pow2Floor(double a) +{ + return std::pow(2.0, std::logb(a)); +} + +static inline int BiasedIntLog2(double a) +{ + return (int)std::logb(a); +} + +static inline double BiasedIntPow2(int a) +{ + if (a >= 0) + return double(1 << a); + else + return 1.0 / double(1 << -a); +} + +#elif (POV_PORTABLE_RADIOSITY == 4) + +static constexpr auto Pow2Bias = 0; + +static inline double Pow2Floor(double a) +{ + return double(1 << std::ilogb(a)); +} + +static inline int BiasedIntLog2(double a) +{ + return std::ilogb(a); +} + +static inline double BiasedIntPow2(int a) +{ + if (a >= 0) + return double(1 << a); + else + return 1.0 / double(1 << -a); +} + +#elif (POV_PORTABLE_RADIOSITY == 5) + +static constexpr auto Pow2Bias = 1023; + +union DoubleHack { double f; std::uint64_t i; }; + +static inline double Pow2Floor(double a) +{ + DoubleHack hack; + hack.f = a; + // Directly clear all mantissa bits (= 1.0) + // while leaving sign and exponent intact. + hack.i &= 0xFFF0000000000000; + return hack.f; +} + +static inline int BiasedIntLog2(double a) +{ + DoubleHack hack; + hack.f = a; + // Directly extract the (biased) float exponent as the final result. + return ((hack.i & 0x7FF0000000000000u) >> 52); +} + +static inline double BiasedIntPow2(int a) +{ + DoubleHack hack; + // Directly copy `a` into the (biased) float exponent, + // while clearing sign and mantissa bits (= positive, 1.0). + hack.i = uint64_t(a) << 52; + return hack.f; +} + +#elif (POV_PORTABLE_RADIOSITY == 6) + +static constexpr auto Pow2Bias = 0; + +static inline float Pow2Floor(float a) +{ + int e; + (void)std::frexpf(a, &e); + return std::ldexpf(0.5f, e); +} + +static inline int BiasedIntLog2(float a) +{ + int e; + (void)std::frexpf(a, &e); + return e - 1; +} + +static inline float BiasedIntPow2(int a) +{ + return std::ldexpf(1.0f, a); +} + +#elif (POV_PORTABLE_RADIOSITY == 7) + +static constexpr auto Pow2Bias = 0; + +static inline float Pow2Floor(float a) +{ + return std::ldexpf(1.0f, std::ilogbf(a)); +} + +static inline int BiasedIntLog2(float a) +{ + return std::ilogbf(a); +} + +static inline float BiasedIntPow2(int a) +{ + return std::ldexpf(1.0f, a); +} + +#elif (POV_PORTABLE_RADIOSITY == 8) + +static constexpr auto Pow2Bias = 0; + +static inline double Pow2Floor(double a) +{ + int e; + (void)std::frexp(a, &e); + return std::ldexp(0.5, e); +} +static inline int BiasedIntLog2(double a) +{ + int e; + (void)std::frexp(a, &e); + return e - 1; +} +static inline double BiasedIntPow2(int a) +{ + return std::ldexpf(1.0, a); +} + +#elif (POV_PORTABLE_RADIOSITY == 9) + +static constexpr auto Pow2Bias = 0; + +static inline double Pow2Floor(double a) +{ + return std::ldexp(1.0, std::ilogb(a)); +} + +static inline int BiasedIntLog2(double a) +{ + return std::ilogb(a); +} + +static inline double BiasedIntPow2(int a) +{ + return std::ldexp(1.0, a); +} + #else - #define POW2OP_DECLARE() // nothing - #define POW2OP_FLOOR(dest,src) \ - (dest) = (DBL)(1 << ilogb(src)); \ - (dest) = copysign((dest), (src)); - #define POW2OP_ENCODE(dest,src) \ - (dest) = ilogb(src) + 127; - #define POW2OP_DECODE(dest,src) \ - if( (src) >= 127 ) (dest) = (DBL)(1 << ((src) - 127)); \ - else (dest) = 1.0 / (DBL)(1 << (127 - (src))); +#error "Unsupported POV_PORTABLE_RADIOSITY setting." #endif - +//****************************************************************************** bool ot_save_node (const Vector3d& point, OT_ID *node); bool ot_traverse (OT_NODE *subtree, bool (*function)(OT_BLOCK *block, void * handle1), void * handle2); @@ -258,19 +520,6 @@ void ot_ins(OT_NODE **root_ptr, OT_BLOCK *new_block, const OT_ID *new_id) if (*root_ptr == nullptr) { -// CLi moved C99_COMPATIBLE_RADIOSITY check from ot_newroot() to ot_ins() `nullptr` root handling section -// (no need to do this again and again for every new node inserted) -#if(C99_COMPATIBLE_RADIOSITY == 0) - if((sizeof(int) != 4) || (sizeof(float) != 4)) - { - throw POV_EXCEPTION_STRING("Radiosity is not available in this unofficial version because\n" - "the person who made this unofficial version available did not\n" - "properly check for compatibility on your platform.\n" - "Look for C99_COMPATIBLE_RADIOSITY in the source code to find\n" - "out how to correct this."); - } -#endif - *root_ptr = new OT_NODE; #ifdef RADSTATS @@ -482,9 +731,6 @@ void ot_newroot(OT_NODE **root_ptr) index = dx + dy + dz; newroot->Kids[index] = *root_ptr; *root_ptr = newroot; - -// CLi moved C99_COMPATIBLE_RADIOSITY check from ot_newroot() to ot_ins() `nullptr` root handling section -// (no need to do this again and again for every new node inserted) } @@ -588,7 +834,7 @@ bool ot_dist_traverse(OT_NODE *subtree, const Vector3d& point, int bounce_depth, while (this_block != nullptr) { #ifdef RADSTATS - if (subtree->Id.Size < 100 || subtree->Id.Size > 140 ) + if ((subtree->Id.Size < Pow2Bias - 27) || (subtree->Id.Size > Pow2Bias + 13)) { Debug_Info("bounds error, unreasonable size %d\n", subtree->Id.Size); } @@ -739,21 +985,8 @@ inline bool ot_point_in_node(const Vector3d& point, const OT_ID *id) { DBL sized; - // sized = 2.0^(size-127) -#if(C99_COMPATIBLE_RADIOSITY == 0) - // speed hack exploiting standard IEEE float binary representation - union - { - float f; // MUST be float, NOT DBL - int l; - } size; - size.l = id->Size << 23; - sized = (DBL) size.f; -#else - // can't use speed hack, do it the official way - if( id->Size >= 127 ) sized = (DBL)(1 << (id->Size - 127)); - else sized = 1.0 / (DBL)(1 << (127 - id->Size)); -#endif + // sized = 2.0^(size-Pow2Bias) + sized = BiasedIntPow2(id->Size); if (fabs(point.x() + OT_BIAS - ((DBL) id->x + 0.5) * sized) >= sized) return false; if (fabs(point.y() + OT_BIAS - ((DBL) id->y + 0.5) * sized) >= sized) return false; @@ -785,7 +1018,7 @@ inline bool ot_point_in_node(const Vector3d& point, const OT_ID *id) * Return the oct-tree index for an object with the specified bounding * sphere. This is the smallest box in the tree that this object fits in with * a maximum 50% hand-over in any (or all) directions. For example, an object -* at (.49, .49, 49) of radius 1 fits in the box (0,0,0) size 127 (length 1). +* at (.49, .49, 49) of radius 1 fits in the box (0,0,0) size Pow2Bias (length 1). * * THREAD SAFETY * @@ -802,6 +1035,9 @@ void ot_index_sphere(const Vector3d& point, DBL radius, OT_ID *id) { Vector3d min_point, max_point; + // TODO FIXME - This transformation from center/radius to min/max is a waste of effort, + // as `ot_index_box` will actually convert it back to center/radius anyway. + min_point = point - radius; max_point = point + radius; @@ -845,16 +1081,7 @@ void ot_index_sphere(const Vector3d& point, DBL radius, OT_ID *id) * smallest box in the tree that this object fits in with a maximum 50% * hang-over in any (or all) directions. For example, an object with extent * (-.49, -.49, -49) to (1.49, 1.49, 1.49) is the largest that fits in the -* box (0,0,0) with size 127 (length 1). -* -* PORTABILITY WARNING: this function REQUIRES IEEE single precision floating -* point format to work. This is true of most common systems except VAXen, -* Crays, and Alpha AXP in VAX compatibility mode. Local "float" variables -* can NOT be made double precision "double" or "DBL". -* -* NOTE: In general the above note is no longer valid, you can use the -* C99_COMPATIBLE_RADIOSITY define explained near the top of this file -* to resolve this problem with recent compilers and libraries [trf] +* box (0,0,0) with size Pow2Bias (length 1). * * THREAD SAFETY * @@ -873,10 +1100,9 @@ void ot_index_box(const Vector3d& min_point, const Vector3d& max_point, OT_ID *i DBL dx, dy, dz, desiredSize; DBL bsized, maxord; - POW2OP_DECLARE() // Calculate the absolute minimum required size of the node, assuming it is perfectly centered within the node; - // Node size must be a power of 2, and be large enough to accomodate box's biggest dimensions with maximum overhang to all sides + // Node size must be a power of 2, and be large enough to accommodate box's biggest dimensions with maximum overhang to all sides // compute ideal size of the node for a perfect fit without any overhang dx = max_point.x() - min_point.x(); @@ -890,7 +1116,7 @@ void ot_index_box(const Vector3d& min_point, const Vector3d& max_point, OT_ID *i // compute best-matching power-of-two size for a perfect fit with overhang // (Note: theoretically this might pick a size larger than required if desiredSize is already a power of two) // desiredSize *= 2.0; - POW2OP_FLOOR(bsized,desiredSize) + bsized = Pow2Floor(desiredSize); // avoid divisions by zero if(bsized == 0.0) @@ -919,7 +1145,7 @@ void ot_index_box(const Vector3d& min_point, const Vector3d& max_point, OT_ID *i id->x = (int) floor((center[X] + OT_BIAS) / bsized); id->y = (int) floor((center[Y] + OT_BIAS) / bsized); id->z = (int) floor((center[Z] + OT_BIAS) / bsized); - POW2OP_ENCODE(id->Size, bsized) + id->Size = BiasedIntLog2(bsized); #ifdef RADSTATS thisloops = 0; @@ -943,7 +1169,7 @@ void ot_index_box(const Vector3d& min_point, const Vector3d& max_point, OT_ID *i #endif #ifdef OT_DEBUG - if (id->Size > 139) + if (id->Size > Pow2Bias + 12) { Debug_Info("unusually large id, maxdel=%.4f, bsized=%.4f, isize=%d\n", maxdel, bsized, id->Size); @@ -1397,4 +1623,5 @@ bool ot_read_file(OT_NODE **root, IStream *fd, const OT_READ_PARAM* param, OT_RE return retval; } -} // end of namespace +} +// end of namespace pov diff --git a/source/core/support/octree.h b/source/core/support/octree.h index 5ec8f2088..9944c05d8 100644 --- a/source/core/support/octree.h +++ b/source/core/support/octree.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,18 +45,21 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/support/octree_fwd.h" +// C++ variants of C standard header files #include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/vector.h" -namespace pov_base -{ -class IStream; -class OStream; -} - namespace pov { @@ -73,8 +76,7 @@ using namespace pov_base; * Global preprocessor defines ******************************************************************************/ -// The addressing scheme of the nodes has a fundamental problem in that it is -// incapable of providing a common root for nodes which have IDs with differing signs. +// The addressing scheme of the nodes has an issue near the origin that impedes performance. // We're working around this by adding a large positive bias when computing node IDs. #define OT_BIAS 10000000. @@ -86,26 +88,20 @@ using namespace pov_base; typedef unsigned short OT_TILE; #define OT_TILE_MAX USHRT_MAX -typedef unsigned char OT_PASS; -#define OT_PASS_INVALID 0 -#define OT_PASS_FIRST 1 -#define OT_PASS_FINAL UCHAR_MAX -#define OT_PASS_MAX (OT_PASS_FINAL-2) // OT_PASS_FINAL-1 is reserved - -typedef unsigned char OT_DEPTH; -#define OT_DEPTH_MAX UCHAR_MAX +using OT_PASS = OctreePass; ///< @deprecated +constexpr auto OT_PASS_INVALID = kOctreePassInvalid; ///< @deprecated +constexpr auto OT_PASS_FIRST = kOctreePassFirst; ///< @deprecated +constexpr auto OT_PASS_FINAL = kOctreePassFinal; ///< @deprecated +constexpr auto OT_PASS_MAX = kOctreePassMax; ///< @deprecated -typedef struct ot_block_struct OT_BLOCK; -typedef struct ot_id_struct OT_ID; -typedef struct ot_node_struct OT_NODE; -typedef struct ot_read_param_struct OT_READ_PARAM; -typedef struct ot_read_info_struct OT_READ_INFO; +using OT_DEPTH = OctreeDepth; +constexpr auto OT_DEPTH_MAX = kOctreeDepthMax; ///< @deprecated // Each node in the oct-tree has a (possibly null) linked list of these data blocks off it. -struct ot_block_struct +struct ot_block_struct final { // TODO for memory efficiency we could probably use single-precision data types for the vector stuff - OT_BLOCK *next; // next block in the same node + ot_block_struct* next; // next block in the same node Vector3d Point; Vector3d S_Normal; Vector3d To_Nearest_Surface; @@ -119,40 +115,45 @@ struct ot_block_struct OT_PASS Pass; // pass during which this sample was taken (OT_PASS_FINAL for final render) OT_DEPTH Bounce_Depth; }; +using OT_BLOCK = ot_block_struct; ///< @deprecated // This is the information necessary to name an oct-tree node. -struct ot_id_struct +struct ot_id_struct final { int x, y, z; int Size; ot_id_struct() : x(0), y(0), z(0), Size(0) {} }; +using OT_ID = ot_id_struct; ///< @deprecated // These are the structures that make up the oct-tree itself, known as nodes -struct ot_node_struct +struct ot_node_struct final { OT_ID Id; OT_BLOCK *Values; - OT_NODE *Kids[8]; + ot_node_struct *Kids[8]; ot_node_struct() : Id(), Values(nullptr) { for (unsigned int i = 0; i < 8; i ++) { Kids[i] = nullptr; } } }; +using OT_NODE = ot_node_struct; ///< @deprecated // These are informations the octree reader needs to know -struct ot_read_param_struct +struct ot_read_param_struct final { DBL RealErrorBound; }; +using OT_READ_PARAM = ot_read_param_struct; ///< @deprecated // These are informations the octree reader generates -struct ot_read_info_struct +struct ot_read_info_struct final { MathColour Gather_Total; long Gather_Total_Count; DBL Brightness; bool FirstRadiosityPass; }; +using OT_READ_INFO = ot_read_info_struct; ///< @deprecated /***************************************************************************** * Global functions @@ -174,5 +175,6 @@ void ot_parent (OT_ID *dad, OT_ID *kid); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_OCTREE_H diff --git a/source/core/support/octree_fwd.h b/source/core/support/octree_fwd.h new file mode 100644 index 000000000..5020b9c14 --- /dev/null +++ b/source/core/support/octree_fwd.h @@ -0,0 +1,62 @@ +//****************************************************************************** +/// +/// @file core/support/octree_fwd.h +/// +/// Forward declarations related to the radiosity sample octree. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_CORE_OCTREE_FWD_H +#define POVRAY_CORE_OCTREE_FWD_H + +// C++ standard header files +#include + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +using OctreePass = unsigned short; +constexpr auto kOctreePassInvalid = 0; +constexpr auto kOctreePassFirst = 1; +constexpr auto kOctreePassFinal = std::numeric_limits::max(); +constexpr auto kOctreePassReserved = kOctreePassFinal - 1; +constexpr auto kOctreePassMax = kOctreePassReserved - 1; + +using OctreeDepth = unsigned char; +constexpr auto kOctreeDepthMax = std::numeric_limits::max(); + +} +// end of namespace pov + +#endif // POVRAY_CORE_OCTREE_FWD_H diff --git a/source/core/support/simplevector.h b/source/core/support/simplevector.h index 39c0422b8..645d4b4e5 100644 --- a/source/core/support/simplevector.h +++ b/source/core/support/simplevector.h @@ -29,7 +29,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -60,10 +60,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +#include + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/coretypes.h" namespace pov @@ -86,8 +92,8 @@ namespace pov // This is intentional as we currently do not store any objects in it that // require this functionality. // TODO FIXME //////////////////////////////////////////////////////////////////////////// -template > -class SimpleVector +template> +class SimpleVector final { public: typedef SimpleVector MyType; @@ -406,7 +412,7 @@ class SimpleVector // require this functionality. //////////////////////////////////////////////////////////////////////////// template -class FixedSimpleVector +class FixedSimpleVector final { public: typedef FixedSimpleVector MyType; @@ -623,7 +629,7 @@ class FixedSimpleVector /// such cases gracefully. /// template -class VectorPool +class VectorPool final { public: @@ -670,7 +676,7 @@ class VectorPool private: - vector mPool; + std::vector mPool; size_t mSizeHint; }; @@ -684,7 +690,7 @@ class VectorPool /// require this functionality. /// template -class PooledSimpleVector +class PooledSimpleVector final { public: @@ -792,5 +798,6 @@ class PooledSimpleVector //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SIMPLEVECTOR_H diff --git a/source/core/support/statisticids.cpp b/source/core/support/statisticids.cpp index 36ff391c4..439e00864 100644 --- a/source/core/support/statisticids.cpp +++ b/source/core/support/statisticids.cpp @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -37,6 +37,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/support/statisticids.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -167,3 +175,4 @@ const INTERSECTION_STATS_INFO intersection_stats[kPOVList_Stat_Last] = }; } +// end of namespace pov diff --git a/source/core/support/statisticids.h b/source/core/support/statisticids.h index 01841f14f..f9e41a73c 100644 --- a/source/core/support/statisticids.h +++ b/source/core/support/statisticids.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,7 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "base/types.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) namespace pov { @@ -332,13 +338,14 @@ typedef enum FPSTATS MaxFPStat } FPStatsIndex; -typedef struct intersection_stats_info +struct intersection_stats_info final { int povms_id; IntStatsIndex stat_test_id; IntStatsIndex stat_suc_id; const char *infotext; -} INTERSECTION_STATS_INFO; +}; +using INTERSECTION_STATS_INFO = intersection_stats_info; ///< @deprecated extern const INTERSECTION_STATS_INFO intersection_stats[]; @@ -347,5 +354,6 @@ extern const INTERSECTION_STATS_INFO intersection_stats[]; //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_STATISTICIDS_H diff --git a/source/core/support/statistics.cpp b/source/core/support/statistics.cpp index 9dfeaecd7..86bd0fe51 100644 --- a/source/core/support/statistics.cpp +++ b/source/core/support/statistics.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,10 +36,13 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/support/statistics.h" -#include -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) -#include "base/types.h" +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) // this must be the last file included #include "base/povdebug.h" @@ -104,3 +107,4 @@ template class StatisticsBase; template class StatisticsBase; } +// end of namespace pov diff --git a/source/core/support/statistics.h b/source/core/support/statistics.h index db6ff6b25..dd076f6f1 100644 --- a/source/core/support/statistics.h +++ b/source/core/support/statistics.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include +// C++ variants of C standard header files +#include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/support/statisticids.h" namespace pov @@ -53,10 +61,8 @@ namespace pov /// /// @{ -using namespace pov_base; - template -class Counter +class Counter final { public: Counter() { value = 0; } // assumes for all types of T that 0 is a valid assignment @@ -76,14 +82,14 @@ class Counter }; template -class StatisticsBase +class StatisticsBase final { public: StatisticsBase() {} virtual ~StatisticsBase() {} - inline Counter& operator[](size_t idx) { return counters[idx]; } - inline Counter operator[](size_t idx) const { return counters[idx]; } + inline Counter& operator[](std::size_t idx) { return counters[idx]; } + inline Counter operator[](std::size_t idx) const { return counters[idx]; } void operator+=(const StatisticsBase& other); StatisticsBase operator+(const StatisticsBase& other); @@ -97,7 +103,7 @@ class StatisticsBase typedef StatisticsBase IntStatistics; typedef StatisticsBase FPStatistics; -class RenderStatistics +class RenderStatistics final { public: RenderStatistics() {} @@ -123,5 +129,6 @@ class RenderStatistics //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_STATISTICS_H diff --git a/source/frontend/animationprocessing.cpp b/source/frontend/animationprocessing.cpp index 4f341000c..b067cbd55 100644 --- a/source/frontend/animationprocessing.cpp +++ b/source/frontend/animationprocessing.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,21 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/animationprocessing.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -49,20 +62,20 @@ AnimationProcessing::AnimationProcessing(POVMS_Object& options) : { bool cyclic = renderOptions.TryGetBool(kPOVAttrib_CyclicAnimation, false); - initialFrame = max(renderOptions.TryGetInt(kPOVAttrib_InitialFrame, 1), 0); + initialFrame = std::max(renderOptions.TryGetInt(kPOVAttrib_InitialFrame, 1), 0); initialClock = renderOptions.TryGetFloat(kPOVAttrib_InitialClock, 0.0); - finalFrame = max(renderOptions.TryGetInt(kPOVAttrib_FinalFrame, 1), initialFrame); + finalFrame = std::max(renderOptions.TryGetInt(kPOVAttrib_FinalFrame, 1), initialFrame); finalClock = renderOptions.TryGetFloat(kPOVAttrib_FinalClock, 1.0); - frameStep = max(renderOptions.TryGetInt(kPOVAttrib_FrameStep, 1), 1); + frameStep = std::max(renderOptions.TryGetInt(kPOVAttrib_FrameStep, 1), 1); if(cyclic == true) finalFrame++; if(renderOptions.Exist(kPOVAttrib_SubsetStartFrame) == true) { - POVMSFloat subsetStartPercent = max(renderOptions.GetFloat(kPOVAttrib_SubsetStartFrame), POVMSFloat(0.0)); + POVMSFloat subsetStartPercent = std::max(renderOptions.GetFloat(kPOVAttrib_SubsetStartFrame), POVMSFloat(0.0)); if((subsetStartPercent == 0.0) || (subsetStartPercent >= 1.0)) subsetStartFrame = POVMSInt(subsetStartPercent); else @@ -75,7 +88,7 @@ AnimationProcessing::AnimationProcessing(POVMS_Object& options) : if(options.Exist(kPOVAttrib_SubsetEndFrame) == true) { - POVMSFloat subsetEndPercent = max(renderOptions.GetFloat(kPOVAttrib_SubsetEndFrame), POVMSFloat(0.0)); + POVMSFloat subsetEndPercent = std::max(renderOptions.GetFloat(kPOVAttrib_SubsetEndFrame), POVMSFloat(0.0)); if((subsetEndPercent == 0.0) || (subsetEndPercent >= 1.0)) subsetEndFrame = POVMSInt(subsetEndPercent); else @@ -218,3 +231,4 @@ int AnimationProcessing::GetFrameNumberDigits() } } +// end of namespace pov_frontend diff --git a/source/frontend/animationprocessing.h b/source/frontend/animationprocessing.h index cc5dbd4d0..10022c431 100644 --- a/source/frontend/animationprocessing.h +++ b/source/frontend/animationprocessing.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,16 +39,25 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" -#include "base/types.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +// (none at the moment) + namespace pov_frontend { using namespace pov_base; -class AnimationProcessing +class AnimationProcessing final { public: AnimationProcessing(POVMS_Object& options); @@ -100,5 +109,6 @@ class AnimationProcessing }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_ANIMATIONPROCESSING_H diff --git a/source/frontend/configfrontend.h b/source/frontend/configfrontend.h index adc5e3981..d4d2a0da7 100644 --- a/source/frontend/configfrontend.h +++ b/source/frontend/configfrontend.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,6 +38,7 @@ #ifndef POVRAY_FRONTEND_CONFIGFRONTEND_H #define POVRAY_FRONTEND_CONFIGFRONTEND_H +// Pull in other compile-time config header files first #include "base/configbase.h" #include "syspovconfigfrontend.h" diff --git a/source/frontend/console.cpp b/source/frontend/console.cpp index 90456a683..b7c0cf356 100644 --- a/source/frontend/console.cpp +++ b/source/frontend/console.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,13 +36,22 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/console.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (POVMS module) +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" namespace pov_frontend { -Console::Console(unsigned int wrapwidth) : TextStreamBuffer(1024*8, wrapwidth) +Console::Console(unsigned int wrapwidth) : pov_base::TextStreamBuffer(1024*8, wrapwidth) { // nothing to do } @@ -54,7 +63,8 @@ Console::~Console() void Console::lineoutput(const char *str, unsigned int chars) { - Output(string(str, chars)); + Output(std::string(str, chars)); } } +// end of namespace pov_frontend diff --git a/source/frontend/console.h b/source/frontend/console.h index 7eae4850b..a3039fe78 100644 --- a/source/frontend/console.h +++ b/source/frontend/console.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,28 +38,37 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +#include "frontend/console_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/textstreambuffer.h" +// POV-Ray header files (POVMS module) +// POV-Ray header files (frontend module) +// (none at the moment) + namespace pov_frontend { -using namespace pov_base; - -class Console : public TextStreamBuffer +class Console : public pov_base::TextStreamBuffer { public: Console(unsigned int wrapwidth = 80); - virtual ~Console(); + virtual ~Console() override; virtual void Initialise() = 0; - virtual void Output(const string&) = 0; + virtual void Output(const std::string&) = 0; private: - void lineoutput(const char *str, unsigned int chars); + virtual void lineoutput(const char *str, unsigned int chars) override; }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_CONSOLE_H diff --git a/source/frontend/console_fwd.h b/source/frontend/console_fwd.h new file mode 100644 index 000000000..0b55c30d4 --- /dev/null +++ b/source/frontend/console_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file frontend/console_fwd.h +/// +/// Forward declarations related to ... what? +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_FRONTEND_CONSOLE_FWD_H +#define POVRAY_FRONTEND_CONSOLE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_frontend +{ + +class Console; + +} +// end of namespace pov_frontend + +#endif // POVRAY_FRONTEND_CONSOLE_FWD_H diff --git a/source/frontend/display.cpp b/source/frontend/display.cpp index 865baa293..9e1b18c97 100644 --- a/source/frontend/display.cpp +++ b/source/frontend/display.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/display.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (POVMS module) +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -105,3 +114,4 @@ void Display::Clear() } } +// end of namespace pov_frontend diff --git a/source/frontend/display.h b/source/frontend/display.h index 71c9a403b..84ec9acb8 100644 --- a/source/frontend/display.h +++ b/source/frontend/display.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,13 +39,25 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (POVMS module) +// POV-Ray header files (frontend module) +// (none at the moment) + namespace pov_frontend { class Display { public: - struct RGBA8 { unsigned char red, green, blue, alpha; }; + struct RGBA8 final + { + unsigned char red, green, blue, alpha; + }; Display(unsigned int w, unsigned int h); virtual ~Display(); @@ -69,10 +81,10 @@ class Display /// display height unsigned int height; - /// not available - Display(); + Display() = delete; }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_DISPLAY_H diff --git a/source/frontend/filemessagehandler.cpp b/source/frontend/filemessagehandler.cpp index 0d6f5950a..974e2a7e5 100644 --- a/source/frontend/filemessagehandler.cpp +++ b/source/frontend/filemessagehandler.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,8 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/filemessagehandler.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/fileinputoutput.h" +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (frontend module) #include "frontend/renderfrontend.h" // this must be the last file included @@ -46,6 +55,10 @@ namespace pov_frontend { +using namespace pov_base; + +using std::list; + FileMessageHandler::FileMessageHandler() { } @@ -138,3 +151,4 @@ Path FileMessageHandler::FindFilePath(const list& lps, const Path& f) } } +// end of namespace pov_frontend diff --git a/source/frontend/filemessagehandler.h b/source/frontend/filemessagehandler.h index 528cf5793..08d26b0f3 100644 --- a/source/frontend/filemessagehandler.h +++ b/source/frontend/filemessagehandler.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,22 +39,24 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) +#include "base/path_fwd.h" + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" -namespace pov_base -{ -class Path; -} +// POV-Ray header files (frontend module) +#include "frontend/renderfrontend_fwd.h" namespace pov_frontend { -using namespace pov_base; - -struct SceneData; - class FileMessageHandler { public: @@ -63,13 +65,14 @@ class FileMessageHandler void HandleMessage(const SceneData&, POVMSType, POVMS_Object&, POVMS_Object&); protected: - virtual bool FindFile(const list&, POVMS_Object&, POVMS_Object&); - virtual bool ReadFile(const list&, POVMS_Object&, POVMS_Object&); + virtual bool FindFile(const std::list&, POVMS_Object&, POVMS_Object&); + virtual bool ReadFile(const std::list&, POVMS_Object&, POVMS_Object&); virtual void CreatedFile(POVMS_Object&); - Path FindFilePath(const list&, const Path&); + pov_base::Path FindFilePath(const std::list&, const pov_base::Path&); }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_FILEMESSAGEHANDLER_H diff --git a/source/frontend/imagemessagehandler.cpp b/source/frontend/imagemessagehandler.cpp index 084601d86..d99357fee 100644 --- a/source/frontend/imagemessagehandler.cpp +++ b/source/frontend/imagemessagehandler.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,12 +36,23 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/imagemessagehandler.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + // POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/types.h" #include "base/image/colourspace.h" #include "base/image/dither.h" #include "base/image/encoding.h" #include "base/image/image.h" +// POV-Ray header files (POVMS module) +// (none at the moment) + // POV-Ray header files (frontend module) #include "frontend/display.h" #include "frontend/renderfrontend.h" @@ -52,6 +63,8 @@ namespace pov_frontend { +using std::vector; + ImageMessageHandler::ImageMessageHandler() { } @@ -260,3 +273,4 @@ void ImageMessageHandler::DrawFilledRectangleSet(const SceneData& sd, const View } } +// end of namespace pov_frontend diff --git a/source/frontend/imagemessagehandler.h b/source/frontend/imagemessagehandler.h index a189ee067..16a68ad95 100644 --- a/source/frontend/imagemessagehandler.h +++ b/source/frontend/imagemessagehandler.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,16 +39,24 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +#include "frontend/renderfrontend_fwd.h" + namespace pov_frontend { using namespace pov_base; -struct SceneData; -struct ViewData; - class ImageMessageHandler { public: @@ -65,5 +73,6 @@ class ImageMessageHandler }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_IMAGEMESSAGEHANDLER_H diff --git a/source/frontend/imageprocessing.cpp b/source/frontend/imageprocessing.cpp index 7ea34bde3..6979dafa2 100644 --- a/source/frontend/imageprocessing.cpp +++ b/source/frontend/imageprocessing.cpp @@ -36,16 +36,23 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/imageprocessing.h" -// Standard C++ header files -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) // POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/path.h" +#include "base/image/colourspace.h" #include "base/image/dither.h" #include "base/image/image.h" // POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -56,6 +63,8 @@ namespace pov_frontend { +using std::shared_ptr; + enum { X = 0, @@ -65,7 +74,7 @@ enum ImageProcessing::ImageProcessing(unsigned int width, unsigned int height) { - image = shared_ptr(Image::Create(width, height, Image::RGBFT_Float)); + image = shared_ptr(Image::Create(width, height, ImageDataType::RGBFT_Float)); toStderr = toStdout = false; // TODO FIXME - find a better place for this @@ -79,7 +88,7 @@ ImageProcessing::ImageProcessing(POVMS_Object& ropts) unsigned int blockSize(ropts.TryGetInt(kPOVAttrib_RenderBlockSize, 32)); unsigned int maxBufferMem(ropts.TryGetInt(kPOVAttrib_MaxImageBufferMem, 128)); // number is megabytes - image = shared_ptr(Image::Create(width, height, Image::RGBFT_Float, maxBufferMem, blockSize * blockSize)); + image = shared_ptr(Image::Create(width, height, ImageDataType::RGBFT_Float, maxBufferMem, blockSize * blockSize)); toStdout = OutputIsStdout(ropts); toStderr = OutputIsStderr(ropts); @@ -104,12 +113,12 @@ UCS2String ImageProcessing::WriteImage(POVMS_Object& ropts, POVMSInt frame, int { if(ropts.TryGetBool(kPOVAttrib_OutputToFile, true) == true) { - Image::WriteOptions wopts; + ImageWriteOptions wopts; Image::ImageFileType imagetype = Image::SYS; unsigned int filetype = POV_File_Image_System; wopts.bitsPerChannel = clip(ropts.TryGetInt(kPOVAttrib_BitsPerColor, 8), 1, 16); - wopts.alphaMode = (ropts.TryGetBool(kPOVAttrib_OutputAlpha, false) ? Image::kAlphaMode_Default : Image::kAlphaMode_None ); + wopts.alphaMode = (ropts.TryGetBool(kPOVAttrib_OutputAlpha, false) ? ImageAlphaMode::Default : ImageAlphaMode::None ); wopts.compression = (ropts.Exist(kPOVAttrib_Compression) ? clip(ropts.GetInt(kPOVAttrib_Compression), 0, 255) : -1); wopts.grayscale = ropts.TryGetBool(kPOVAttrib_GrayscaleOutput, false); @@ -347,3 +356,4 @@ UCS2String ImageProcessing::GetOutputFilename(POVMS_Object& ropts, POVMSInt fram } } +// end of namespace pov_frontend diff --git a/source/frontend/imageprocessing.h b/source/frontend/imageprocessing.h index f47d70e19..29b5e13ad 100644 --- a/source/frontend/imageprocessing.h +++ b/source/frontend/imageprocessing.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,14 +39,21 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" -#include "base/stringutilities.h" +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/stringtypes.h" +#include "base/image/image_fwd.h" + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" -namespace pov_base -{ -class Image; -} +// POV-Ray header files (frontend module) +// (none at the moment) namespace pov_frontend { @@ -58,12 +65,12 @@ class ImageProcessing public: ImageProcessing(unsigned int width, unsigned int height); ImageProcessing(POVMS_Object& ropts); - ImageProcessing(shared_ptr& img); + ImageProcessing(std::shared_ptr& img); virtual ~ImageProcessing(); UCS2String WriteImage(POVMS_Object& ropts, POVMSInt frame = 0, int digits = 0); - shared_ptr& GetImage(); + std::shared_ptr& GetImage(); UCS2String GetOutputFilename(POVMS_Object& ropts, POVMSInt frame, int digits); bool OutputIsStdout(void) { return toStdout; } @@ -72,16 +79,18 @@ class ImageProcessing virtual bool OutputIsStderr(POVMS_Object& ropts); protected: - shared_ptr image; + std::shared_ptr image; bool toStdout; bool toStderr; private: - ImageProcessing(); - ImageProcessing(const ImageProcessing&); - ImageProcessing& operator=(const ImageProcessing&); + + ImageProcessing() = delete; + ImageProcessing(const ImageProcessing&) = delete; + ImageProcessing& operator=(const ImageProcessing&) = delete; }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_IMAGEPROCESSING_H diff --git a/source/frontend/parsermessagehandler.cpp b/source/frontend/parsermessagehandler.cpp index 5af2bd611..5cdcdf304 100644 --- a/source/frontend/parsermessagehandler.cpp +++ b/source/frontend/parsermessagehandler.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/parsermessagehandler.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (frontend module) #include "frontend/renderfrontend.h" // this must be the last file included @@ -196,9 +207,10 @@ void ParserMessageHandler::DebugInfo(Console *console, POVMS_Object& obj, bool c if(conout == true) { // TODO FIXME HACK - string str(obj.GetString(kPOVAttrib_EnglishText)); + std::string str(obj.GetString(kPOVAttrib_EnglishText)); console->Output(str); } } } +// end of namespace pov_frontend diff --git a/source/frontend/parsermessagehandler.h b/source/frontend/parsermessagehandler.h index 6606ee6ce..721c949c0 100644 --- a/source/frontend/parsermessagehandler.h +++ b/source/frontend/parsermessagehandler.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,14 +39,20 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +#include "frontend/console_fwd.h" +#include "frontend/renderfrontend_fwd.h" + namespace pov_frontend { -class Console; -struct SceneData; - class ParserMessageHandler { public: @@ -65,5 +71,6 @@ class ParserMessageHandler }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_PARSERMESSAGEHANDLER_H diff --git a/source/frontend/precomp.h b/source/frontend/precomp.h index c593b2096..70db91f1e 100644 --- a/source/frontend/precomp.h +++ b/source/frontend/precomp.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "base/configbase.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,13 +70,11 @@ #include #include +// Boost header files #include #include #include #include -#include -#include -#include #if POV_MULTITHREADED #include #include diff --git a/source/frontend/processoptions.cpp b/source/frontend/processoptions.cpp index 807a354d5..2c0bcdb3e 100644 --- a/source/frontend/processoptions.cpp +++ b/source/frontend/processoptions.cpp @@ -36,12 +36,29 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/processoptions.h" +// C++ variants of C standard header files +#include #include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/platformbase.h" +#include "base/povassert.h" +#include "base/stringutilities.h" +#include "base/textstream.h" + +// POV-Ray header files (core module) +// (none at the moment) +// POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -1498,3 +1515,4 @@ int ProcessOptions::Process_Switch(Cmd_Parser_Table *option, char *param, POVMSO } } +// end of namespace pov_frontend diff --git a/source/frontend/processoptions.h b/source/frontend/processoptions.h index c131c49b4..4bdb57ed2 100644 --- a/source/frontend/processoptions.h +++ b/source/frontend/processoptions.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -34,16 +34,29 @@ /// //****************************************************************************** -#ifndef PROCESSOPTIONS_H -#define PROCESSOPTIONS_H +#ifndef POVRAY_FRONTEND_PROCESSOPTIONS_H +#define POVRAY_FRONTEND_PROCESSOPTIONS_H // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" -#include "base/textstream.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) +#include "base/stringtypes.h" +#include "base/textstream_fwd.h" + +// POV-Ray header files (core module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +// (none at the moment) + namespace pov_frontend { @@ -60,7 +73,7 @@ enum { class ProcessOptions { public: - struct INI_Parser_Table + struct INI_Parser_Table final { const char *keyword; POVMSType key; @@ -68,7 +81,7 @@ class ProcessOptions int flags; }; - struct Cmd_Parser_Table + struct Cmd_Parser_Table final { const char *command; POVMSType key; @@ -78,7 +91,7 @@ class ProcessOptions }; ProcessOptions(INI_Parser_Table *, Cmd_Parser_Table *); - ~ProcessOptions(); + virtual ~ProcessOptions(); int ParseFile(const char *, POVMSObjectPtr); int ParseString(const char *, POVMSObjectPtr, bool singleswitch = false); @@ -141,5 +154,6 @@ class ProcessOptions }; } +// end of namespace pov_frontend -#endif +#endif // POVRAY_FRONTEND_PROCESSOPTIONS_H diff --git a/source/frontend/processrenderoptions.cpp b/source/frontend/processrenderoptions.cpp index f3b264b20..818633d54 100644 --- a/source/frontend/processrenderoptions.cpp +++ b/source/frontend/processrenderoptions.cpp @@ -39,16 +39,28 @@ // C++ variants of C standard header files #include +// C++ standard header files +// (none at the moment) + // POV-Ray header files (base module) #include "base/fileutil.h" #include "base/platformbase.h" +#include "base/stringutilities.h" #include "base/image/colourspace.h" #include "base/image/dither.h" #include "base/image/encoding.h" +// POV-Ray header files (core module) +#include "base/fileinputoutput.h" +#include "base/path.h" +#include "base/textstream.h" + // POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -1221,3 +1233,4 @@ const char* ProcessRenderOptions::GetParameterCodeText(const ProcessRenderOption } } +// end of namespace pov_frontend diff --git a/source/frontend/processrenderoptions.h b/source/frontend/processrenderoptions.h index 4c2d7995b..9c92aee08 100644 --- a/source/frontend/processrenderoptions.h +++ b/source/frontend/processrenderoptions.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,8 +39,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) #include "frontend/processoptions.h" namespace pov_frontend @@ -52,15 +62,15 @@ class ProcessRenderOptions : public ProcessOptions { public: ProcessRenderOptions(); - ~ProcessRenderOptions(); + virtual ~ProcessRenderOptions() override; protected: - virtual int ReadSpecialOptionHandler(INI_Parser_Table *, char *, POVMSObjectPtr); - virtual int ReadSpecialSwitchHandler(Cmd_Parser_Table *, char *, POVMSObjectPtr, bool); - virtual int WriteSpecialOptionHandler(INI_Parser_Table *, POVMSObjectPtr, OTextStream *); - virtual int ProcessUnknownString(char *, POVMSObjectPtr); + virtual int ReadSpecialOptionHandler(INI_Parser_Table *, char *, POVMSObjectPtr) override; + virtual int ReadSpecialSwitchHandler(Cmd_Parser_Table *, char *, POVMSObjectPtr, bool) override; + virtual int WriteSpecialOptionHandler(INI_Parser_Table *, POVMSObjectPtr, OTextStream *) override; + virtual int ProcessUnknownString(char *, POVMSObjectPtr) override; - virtual ITextStream *OpenFileForRead(const char *, POVMSObjectPtr); - virtual OTextStream *OpenFileForWrite(const char *, POVMSObjectPtr); + virtual ITextStream *OpenFileForRead(const char *, POVMSObjectPtr) override; + virtual OTextStream *OpenFileForWrite(const char *, POVMSObjectPtr) override; ITextStream *OpenINIFileStream(const char *, unsigned int, POVMSObjectPtr); public: @@ -94,5 +104,6 @@ class ProcessRenderOptions : public ProcessOptions }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_PROCESSRENDEROPTIONS_H diff --git a/source/frontend/renderfrontend.cpp b/source/frontend/renderfrontend.cpp index a3a5f4319..f0cb9c2d2 100644 --- a/source/frontend/renderfrontend.cpp +++ b/source/frontend/renderfrontend.cpp @@ -36,13 +36,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/renderfrontend.h" -// Standard C++ header files -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include // POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/platformbase.h" #include "base/textstream.h" #include "base/textstreambuffer.h" +#include "base/types.h" +#include "base/image/colourspace.h" #include "base/image/dither.h" #include "base/image/encoding.h" @@ -60,6 +66,9 @@ namespace pov_frontend { +using std::min; +using std::max; + const int gStreamTypeUtilDataCount = 6; static const POVMSType gStreamTypeUtilData[gStreamTypeUtilDataCount] = @@ -101,14 +110,15 @@ void FileMessage(TextStreamBuffer *tsb, int stream, POVMSObjectPtr msg); const char *GetOptionSwitchString(POVMSObjectPtr msg, POVMSType key, bool defaultstate); } +// end of namespace Message2Console -class FileTextStreamBuffer : public TextStreamBuffer +class FileTextStreamBuffer final : public TextStreamBuffer { public: FileTextStreamBuffer(const UCS2 *filename, bool append) : stream(filename, POV_File_Text_Stream, append) { } - virtual ~FileTextStreamBuffer() { flush(); stream.flush(); } + virtual ~FileTextStreamBuffer() override { flush(); stream.flush(); } protected: - virtual void lineoutput(const char *str, unsigned int chars) { stream.printf("%s\n", string(str, chars).c_str()); stream.flush(); } + virtual void lineoutput(const char *str, unsigned int chars) override { stream.printf("%s\n", std::string(str, chars).c_str()); stream.flush(); } private: OTextStream stream; }; @@ -153,7 +163,7 @@ RenderFrontendBase::~RenderFrontendBase() // nothing to do } -void RenderFrontendBase::ConnectToBackend(POVMSAddress backendaddress, POVMS_Object& obj, POVMS_Object *resultobj, shared_ptr& console) +void RenderFrontendBase::ConnectToBackend(POVMSAddress backendaddress, POVMS_Object& obj, POVMS_Object *resultobj, std::shared_ptr& console) { POVMS_Message msg(obj, kPOVMsgClass_BackendControl, kPOVMsgIdent_InitInfo); POVMS_Message result(kPOVObjectClass_ResultData); @@ -610,7 +620,7 @@ void RenderFrontendBase::NewBackup(POVMS_Object& ropts, ViewData& vd, const Path MakeBackupPath(ropts, vd, outputpath); if (!pov_base::PlatformBase::GetInstance().AllowLocalFileAccess (vd.imageBackupFile(), POV_File_Data_Backup, true)) throw POV_EXCEPTION(kCannotOpenFileErr, "Permission denied to create render state output file."); - vd.imageBackup = shared_ptr(new OStream(vd.imageBackupFile().c_str())); + vd.imageBackup = std::shared_ptr(new OStream(vd.imageBackupFile().c_str())); if(vd.imageBackup != nullptr) { Backup_File_Header hdr; @@ -631,14 +641,14 @@ void RenderFrontendBase::NewBackup(POVMS_Object& ropts, ViewData& vd, const Path // we do this test even if the file doesn't exist as we need to write there // eventually anyhow. might as well test if before the render starts ... if(CheckIfFileExists(filename.c_str())) - PlatformBase::GetInstance().DeleteLocalFile (filename.c_str()); + pov_base::Filesystem::DeleteFile(filename); } } else throw POV_EXCEPTION(kCannotOpenFileErr, "Cannot create render state output file."); } -void RenderFrontendBase::ContinueBackup(POVMS_Object& ropts, ViewData& vd, ViewId vid, POVMSInt& serial, vector& skip, const Path& outputpath) +void RenderFrontendBase::ContinueBackup(POVMS_Object& ropts, ViewData& vd, ViewId vid, POVMSInt& serial, std::vector& skip, const Path& outputpath) { bool outputToFile = ropts.TryGetBool(kPOVAttrib_OutputToFile, true); @@ -725,7 +735,7 @@ void RenderFrontendBase::ContinueBackup(POVMS_Object& ropts, ViewData& vd, ViewI // if there isn't going to be an output file, we don't write to the state file if(outputToFile == true) { - vd.imageBackup = shared_ptr(new OStream(vd.imageBackupFile().c_str(), IOBase::append)); + vd.imageBackup = std::shared_ptr(new OStream(vd.imageBackupFile().c_str(), IOBase::append)); if(vd.imageBackup != nullptr) { if(!*vd.imageBackup) @@ -1935,14 +1945,14 @@ void DebugInfo(POVMS_Object& cppmsg, TextStreamBuffer *tsb) tsb->printf("%s\n", str.c_str()); } -string GetProgressTime(POVMS_Object& obj, POVMSType key) +std::string GetProgressTime(POVMS_Object& obj, POVMSType key) { int sec = int(obj.TryGetLong(kPOVAttrib_RealTime, 0) / (POV_LONG)(1000)); char buffer[32]; sprintf(buffer, "%3d:%02d:%02d", int(sec / 3600), int((sec / 60) % 60), int(sec % 60)); - return string(buffer); + return std::string(buffer); } void RenderDone(TextStreamBuffer *tsb, POVMSObjectPtr msg) @@ -2060,5 +2070,7 @@ void Progress(TextStreamBuffer *tsb, POVMSObjectPtr msg) } } +// end of namespace Message2Console } +// end of namespace pov_frontend diff --git a/source/frontend/renderfrontend.h b/source/frontend/renderfrontend.h index 63ac87518..efcabd6cb 100644 --- a/source/frontend/renderfrontend.h +++ b/source/frontend/renderfrontend.h @@ -38,26 +38,38 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +#include "frontend/renderfrontend_fwd.h" -#include +// C++ variants of C standard header files +// (none at the moment) -#include "povms/povmscpp.h" -#include "povms/povmsid.h" +// C++ standard header files +#include +#include +#include +#include +#include +#include +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/filesystem.h" #include "base/path.h" #include "base/platformbase.h" +#include "base/stringutilities.h" +#include "base/textstreambuffer_fwd.h" +#include "base/types.h" +#include "base/image/colourspace.h" #include "base/image/image.h" +// POV-Ray header files (POVMS module) +#include "povms/povmscpp.h" +#include "povms/povmsid.h" + +// POV-Ray header files (frontend module) #include "frontend/console.h" #include "frontend/imageprocessing.h" -namespace pov_base -{ -class TextStreamBuffer; -class Image; -class OStream; -} - namespace pov_frontend { @@ -78,7 +90,7 @@ enum MAX_STREAMS }; -struct SceneData +struct SceneData final { enum SceneState { @@ -96,24 +108,24 @@ struct SceneData SceneState state; - mutable shared_ptr console; + mutable std::shared_ptr console; - mutable list readfiles; - mutable list createdfiles; + mutable std::list readfiles; + mutable std::list createdfiles; Path scenepath; Path outputpath; - list searchpaths; + std::list searchpaths; - shared_ptr streams[MAX_STREAMS]; + std::shared_ptr streams[MAX_STREAMS]; UCS2String streamnames[MAX_STREAMS]; bool consoleoutput[MAX_STREAMS]; bool verbose; - struct + struct final { int legacyGammaMode; // TODO FIXME - conversion from working gamma to linear should be moved to back-end @@ -122,7 +134,7 @@ struct SceneData } backwardCompatibilityData; }; -struct ViewData +struct ViewData final { enum ViewState { @@ -139,9 +151,9 @@ struct ViewData ViewState state; - mutable shared_ptr image; - mutable shared_ptr display; - mutable shared_ptr imageBackup; + mutable std::shared_ptr image; + mutable std::shared_ptr display; + mutable std::shared_ptr imageBackup; GammaCurvePtr displayGamma; bool greyscaleDisplay; @@ -168,23 +180,24 @@ void RenderTime(POVMS_Object& cppmsg, TextStreamBuffer *tsb); void DebugInfo(POVMS_Object& cppmsg, TextStreamBuffer *tsb); -string GetProgressTime(POVMS_Object& obj, POVMSType key); +std::string GetProgressTime(POVMS_Object& obj, POVMSType key); } +// end of namespace Message2Console #define RENDER_STATE_SIG "POV-Ray Render State File\0\0" #define RENDER_STATE_VER "0001" -typedef struct +struct Backup_File_Header final { unsigned char sig[28]; unsigned char ver[4]; unsigned char reserved[480]; -} Backup_File_Header; +}; class RenderFrontendBase : public POVMS_MessageReceiver { - class Id + class Id final { public: Id() : address(POVMSInvalidAddress), identifier(0) { } @@ -212,12 +225,12 @@ class RenderFrontendBase : public POVMS_MessageReceiver RenderFrontendBase(POVMSContext); virtual ~RenderFrontendBase(); - void ConnectToBackend(POVMSAddress, POVMS_Object&, POVMS_Object *, shared_ptr&); + void ConnectToBackend(POVMSAddress, POVMS_Object&, POVMS_Object *, std::shared_ptr&); void DisconnectFromBackend(POVMSAddress); - virtual shared_ptr GetConsole(SceneId) = 0; - virtual shared_ptr GetImage(ViewId) = 0; - virtual shared_ptr GetDisplay(ViewId) = 0; + virtual std::shared_ptr GetConsole(SceneId) = 0; + virtual std::shared_ptr GetImage(ViewId) = 0; + virtual std::shared_ptr GetDisplay(ViewId) = 0; protected: typedef std::set BackendAddressSet; @@ -248,17 +261,19 @@ class RenderFrontendBase : public POVMS_MessageReceiver virtual void HandleRenderMessage(ViewId, POVMSType, POVMS_Object&) = 0; virtual void HandleImageMessage(ViewId, POVMSType, POVMS_Object&) = 0; - virtual void OutputFatalError(const string&, int) = 0; + virtual void OutputFatalError(const std::string&, int) = 0; void MakeBackupPath(POVMS_Object& ropts, ViewData& vd, const Path& outputpath); void NewBackup(POVMS_Object& ropts, ViewData& vd, const Path& outputpath); - void ContinueBackup(POVMS_Object& ropts, ViewData& vd, ViewId vid, POVMSInt& serial, vector& skip, const Path& outputpath); + void ContinueBackup(POVMS_Object& ropts, ViewData& vd, ViewId vid, POVMSInt& serial, std::vector& skip, const Path& outputpath); }; +// TODO - Do we really need this to be a template? + template class RenderFrontend : public RenderFrontendBase { - struct SceneHandler + struct SceneHandler final { SceneData data; @@ -266,7 +281,7 @@ class RenderFrontend : public RenderFrontendBase FILE_MH file; }; - struct ViewHandler + struct ViewHandler final { ViewData data; @@ -275,7 +290,7 @@ class RenderFrontend : public RenderFrontendBase }; public: RenderFrontend(POVMSContext ctx); - ~RenderFrontend(); + virtual ~RenderFrontend() override; SceneId CreateScene(POVMSAddress backendaddress, POVMS_Object& obj, boost::function fn); void CloseScene(SceneId sid); @@ -287,7 +302,7 @@ class RenderFrontend : public RenderFrontendBase void ResumeParser(SceneId sid); void StopParser(SceneId sid); - ViewId CreateView(SceneId sid, POVMS_Object& obj, shared_ptr& imageProcessing, boost::function fn); + ViewId CreateView(SceneId sid, POVMS_Object& obj, std::shared_ptr& imageProcessing, boost::function fn); void CloseView(ViewId vid); ViewData::ViewState GetViewState(ViewId vid); @@ -297,15 +312,15 @@ class RenderFrontend : public RenderFrontendBase void ResumeRender(ViewId vid); void StopRender(ViewId vid); - virtual shared_ptr GetConsole(SceneId sid); - virtual shared_ptr GetImage(ViewId vid); - virtual shared_ptr GetDisplay(ViewId vid); + virtual std::shared_ptr GetConsole(SceneId sid) override; + virtual std::shared_ptr GetImage(ViewId vid) override; + virtual std::shared_ptr GetDisplay(ViewId vid) override; protected: - virtual void HandleParserMessage(SceneId sid, POVMSType ident, POVMS_Object& msg); - virtual void HandleFileMessage(SceneId sid, POVMSType ident, POVMS_Object& msg, POVMS_Object& result); - virtual void HandleRenderMessage(ViewId vid, POVMSType ident, POVMS_Object& msg); - virtual void HandleImageMessage(ViewId vid, POVMSType ident, POVMS_Object& msg); - virtual void OutputFatalError(const string& msg, int err); + virtual void HandleParserMessage(SceneId sid, POVMSType ident, POVMS_Object& msg) override; + virtual void HandleFileMessage(SceneId sid, POVMSType ident, POVMS_Object& msg, POVMS_Object& result) override; + virtual void HandleRenderMessage(ViewId vid, POVMSType ident, POVMS_Object& msg) override; + virtual void HandleImageMessage(ViewId vid, POVMSType ident, POVMS_Object& msg) override; + virtual void OutputFatalError(const std::string& msg, int err) override; private: typedef std::set ViewIdSet; @@ -346,7 +361,7 @@ RenderFrontendBase::SceneId RenderFrontend(fn()); + sh.data.console = std::shared_ptr(fn()); scenehandler[sid] = sh; scene2views[sid] = ViewIdSet(); @@ -436,7 +451,7 @@ void RenderFrontend::StopParser(SceneId } template -RenderFrontendBase::ViewId RenderFrontend::CreateView(SceneId sid, POVMS_Object& obj, shared_ptr& imageProcessing, boost::function fn) +RenderFrontendBase::ViewId RenderFrontend::CreateView(SceneId sid, POVMS_Object& obj, std::shared_ptr& imageProcessing, boost::function fn) { typename SceneHandlerMap::iterator shi(scenehandler.find(sid)); @@ -535,7 +550,7 @@ RenderFrontendBase::ViewId RenderFrontend img(imageProcessing->GetImage()); + std::shared_ptr img(imageProcessing->GetImage()); if (img != nullptr) { if((img->GetWidth() != width) || (img->GetHeight() != height)) @@ -544,11 +559,11 @@ RenderFrontendBase::ViewId RenderFrontend(Image::Create(width, height, Image::RGBFT_Float)); + vh.data.image = std::shared_ptr(Image::Create(width, height, ImageDataType::RGBFT_Float)); } if(obj.TryGetBool(kPOVAttrib_Display, true) == true) - vh.data.display = shared_ptr(fn(width, height)); + vh.data.display = std::shared_ptr(fn(width, height)); viewhandler[vid] = vh; view2scene[vid] = sid; @@ -639,7 +654,7 @@ void RenderFrontend::StartRender(ViewId try { POVMSInt serial; - vector skip; + std::vector skip; ContinueBackup(obj, vhi->second.data, vid, serial, skip, outputpath); @@ -722,33 +737,33 @@ void RenderFrontend::StopRender(ViewId } template -shared_ptr RenderFrontend::GetConsole(SceneId sid) +std::shared_ptr RenderFrontend::GetConsole(SceneId sid) { typename SceneHandlerMap::iterator shi(scenehandler.find(sid)); if(shi != scenehandler.end()) return shi->second.data.console; else - return shared_ptr(); + return std::shared_ptr(); } template -shared_ptr RenderFrontend::GetImage(ViewId vid) +std::shared_ptr RenderFrontend::GetImage(ViewId vid) { typename ViewHandlerMap::iterator vhi(viewhandler.find(vid)); if(vhi != viewhandler.end()) return vhi->second.data.image; else - return shared_ptr(); + return std::shared_ptr(); } template -shared_ptr RenderFrontend::GetDisplay(ViewId vid) +std::shared_ptr RenderFrontend::GetDisplay(ViewId vid) { typename ViewHandlerMap::iterator vhi(viewhandler.find(vid)); if(vhi != viewhandler.end()) return vhi->second.data.display; else - return shared_ptr(); + return std::shared_ptr(); } template @@ -764,7 +779,7 @@ void RenderFrontend::HandleParserMessag } else if(ident == kPOVMsgIdent_Failed) { - string str("Fatal error in parser: "); + std::string str("Fatal error in parser: "); str += msg.TryGetString(kPOVAttrib_EnglishText, "Unknown failure!"); shi->second.data.console->Output(str); shi->second.data.state = SceneData::Scene_Failed; @@ -798,12 +813,12 @@ void RenderFrontend::HandleRenderMessag if (vhi->second.data.imageBackup != nullptr) { vhi->second.data.imageBackup.reset(); - PlatformBase::GetInstance().DeleteLocalFile (vhi->second.data.imageBackupFile().c_str()); + pov_base::Filesystem::DeleteFile(vhi->second.data.imageBackupFile()); } } else if(ident == kPOVMsgIdent_Failed) { - string str("Fatal error in renderer: "); + std::string str("Fatal error in renderer: "); str += msg.TryGetString(kPOVAttrib_EnglishText, "Unknown failure!"); sceneData.console->Output(str); vhi->second.data.state = ViewData::View_Failed; @@ -826,7 +841,7 @@ void RenderFrontend::HandleImageMessage } template -void RenderFrontend::OutputFatalError(const string& msg, int err) +void RenderFrontend::OutputFatalError(const std::string& msg, int err) { // TODO FIXME CONSOLE::OutputFatalError(msg, err); } @@ -856,7 +871,9 @@ namespace Message2TSB void FileMessage(TextStreamBuffer *, int stream, POVMSObjectPtr); const char *GetOptionSwitchString(POVMSObjectPtr, POVMSType, bool defaultstate = false); } +// end of namespace Message2TSB } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_RENDERFRONTEND_H diff --git a/source/frontend/renderfrontend_fwd.h b/source/frontend/renderfrontend_fwd.h new file mode 100644 index 000000000..f0df590d9 --- /dev/null +++ b/source/frontend/renderfrontend_fwd.h @@ -0,0 +1,52 @@ +//****************************************************************************** +/// +/// @file frontend/renderfrontend_fwd.h +/// +/// Forward declarations related to ... what? +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_FRONTEND_RENDERFRONTEND_FWD_H +#define POVRAY_FRONTEND_RENDERFRONTEND_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_frontend +{ + +struct SceneData; +struct ViewData; + +} +// end of namespace pov_frontend + +#endif // POVRAY_FRONTEND_RENDERFRONTEND_FWD_H diff --git a/source/frontend/rendermessagehandler.cpp b/source/frontend/rendermessagehandler.cpp index 8e2a0e5b3..3437853b2 100644 --- a/source/frontend/rendermessagehandler.cpp +++ b/source/frontend/rendermessagehandler.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/rendermessagehandler.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (frontend module) #include "frontend/renderfrontend.h" // this must be the last file included @@ -192,3 +201,4 @@ void RenderMessageHandler::FatalError(Console *console, POVMS_Object& obj, bool } } +// end of namespace pov_frontend diff --git a/source/frontend/rendermessagehandler.h b/source/frontend/rendermessagehandler.h index 72769c08c..8514a57c0 100644 --- a/source/frontend/rendermessagehandler.h +++ b/source/frontend/rendermessagehandler.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,15 +39,23 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +#include "frontend/console_fwd.h" +#include "frontend/renderfrontend_fwd.h" + namespace pov_frontend { -class Console; -struct SceneData; -struct ViewData; - class RenderMessageHandler { public: @@ -65,5 +73,6 @@ class RenderMessageHandler }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_RENDERMESSAGEHANDLER_H diff --git a/source/frontend/shelloutprocessing.cpp b/source/frontend/shelloutprocessing.cpp index 7fbb84d83..5e11f9076 100644 --- a/source/frontend/shelloutprocessing.cpp +++ b/source/frontend/shelloutprocessing.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,10 +36,23 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/shelloutprocessing.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// Boost header files +#include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -85,7 +98,7 @@ ShelloutAction::ShelloutAction(const ShelloutProcessing *sp, unsigned int attrib // expand the parameters in the rawParameters member into the parameters member, applying the escapes // documented below. scene is the scene name, ofn the output file name, w/h the width/height, clock the // current animation clock value, and frame the current frame number. -void ShelloutAction::ExpandParameters(const string& scene, const string& ofn, unsigned int w, unsigned int h, float clock, unsigned int frame) +void ShelloutAction::ExpandParameters(const std::string& scene, const std::string& ofn, unsigned int w, unsigned int h, float clock, unsigned int frame) { // %o: output file name in full // %s: scene name without path or extension @@ -143,7 +156,7 @@ void ShelloutAction::ExpandParameters(const string& scene, const string& ofn, un // ------------------------------------------------------------------ -ShelloutProcessing::ShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height): sceneName(scene), imageWidth(width), imageHeight(height) +ShelloutProcessing::ShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height): sceneName(scene), imageWidth(width), imageHeight(height) { skipReturn = cancelReturn = exitCode = 0; clockVal = 0.0; @@ -185,7 +198,7 @@ ShelloutProcessing::~ShelloutProcessing() // parameters start will not be removed. // // this method should return true if the command is non-empty upon completion. -bool ShelloutProcessing::ExtractCommand(const string& src, string& command, string& parameters) const +bool ShelloutProcessing::ExtractCommand(const std::string& src, std::string& command, std::string& parameters) const { bool inSQ = false; bool inDQ = false; @@ -194,7 +207,7 @@ bool ShelloutProcessing::ExtractCommand(const string& src, string& command, stri command.clear(); parameters.clear(); - string str = boost::trim_copy(src); + std::string str = boost::trim_copy(src); for (s = str.c_str(); *s != '\0'; s++) { if (hadEscape) @@ -234,11 +247,11 @@ bool ShelloutProcessing::ExtractCommand(const string& src, string& command, stri } } - parameters = boost::trim_copy(string(s)); + parameters = boost::trim_copy(std::string(s)); return true; } -string ShelloutProcessing::GetPhaseName(shelloutEvent event) +std::string ShelloutProcessing::GetPhaseName(shelloutEvent event) { switch (event) { @@ -274,7 +287,7 @@ bool ShelloutProcessing::HandleProcessEvent(shelloutEvent event, bool internalCa event = preScene; bool skipWasSet(skipCallouts); - string phaseName(GetPhaseName(event)); + std::string phaseName(GetPhaseName(event)); ShelloutPtr sh(shellouts[event]); switch (event) @@ -366,9 +379,9 @@ bool ShelloutProcessing::HandleProcessEvent(shelloutEvent event, bool internalCa bool ShelloutProcessing::PostProcessEvent(void) { int ret; - string output; + std::string output; shelloutEvent event = postProcessEvent; - string phaseName(GetPhaseName(event)); + std::string phaseName(GetPhaseName(event)); processStartRequested = false; runningProcessName.clear(); @@ -581,7 +594,7 @@ bool ShelloutProcessing::ShelloutRunning(void) // 7: the command parameters (CAUTION: may contain escape codes) // 8: the command return code (as an integer) // 9: output text from the command, as returned by LastShelloutResult() -string ShelloutProcessing::GetCancelMessage(void) +std::string ShelloutProcessing::GetCancelMessage(void) { return str( cancelFormat % cancelPhase @@ -603,7 +616,7 @@ string ShelloutProcessing::GetCancelMessage(void) // 4: the command parameters (CAUTION: may contain escape codes) // 5: the command return code (as an integer) // 6: output text from the command, as returned by LastShelloutResult() -string ShelloutProcessing::GetSkipMessage(void) +std::string ShelloutProcessing::GetSkipMessage(void) { return str( skipFormat % skipPhase @@ -642,9 +655,10 @@ bool ShelloutProcessing::KillShellouts(int timeout, bool force) // if the platform implemeting a subclass of this method has the equivalent of a // system log (e.g. syslog on unix, event log on windows), the implementation should // consider providing a user-controllable option to log any commands using such. -bool ShelloutProcessing::ExecuteCommand(const string& cmd, const string& params) +bool ShelloutProcessing::ExecuteCommand(const std::string& cmd, const std::string& params) { throw POV_EXCEPTION(kCannotOpenFileErr, "Shellouts not implemented on this platform"); } } +// end of namespace pov_frontend diff --git a/source/frontend/shelloutprocessing.h b/source/frontend/shelloutprocessing.h index f2420f308..0096ad57f 100644 --- a/source/frontend/shelloutprocessing.h +++ b/source/frontend/shelloutprocessing.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,16 +39,31 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// Boost header files #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +// (none at the moment) + namespace pov_frontend { class ShelloutProcessing; -class ShelloutAction +class ShelloutAction final { public: typedef enum @@ -66,23 +81,23 @@ class ShelloutAction Action ReturnAction(void) const { return returnAction; } bool IsSet(void) const { return isSet; } - const string& RawCommand(void) const { return rawCommand; } - const string& Command(void) const { return command; } - const string& RawParameters(void) const { return rawParameters; } - const string& Parameters(void) const { return parameters; } + const std::string& RawCommand(void) const { return rawCommand; } + const std::string& Command(void) const { return command; } + const std::string& RawParameters(void) const { return rawParameters; } + const std::string& Parameters(void) const { return parameters; } bool ReturnNegate(void) const { return returnNegate; } - void ExpandParameters(const string& scene, const string& ofn, unsigned int w, unsigned int h, float clock, unsigned int frame); + void ExpandParameters(const std::string& scene, const std::string& ofn, unsigned int w, unsigned int h, float clock, unsigned int frame); private: bool isSet; bool returnNegate; - string command; - string rawCommand; - string parameters; - string rawParameters; + std::string command; + std::string rawCommand; + std::string parameters; + std::string rawParameters; Action returnAction; - ShelloutAction(); + ShelloutAction() = delete; }; class ShelloutProcessing @@ -90,7 +105,7 @@ class ShelloutProcessing friend class ShelloutAction; public: - typedef shared_ptr ShelloutPtr; + typedef std::shared_ptr ShelloutPtr; typedef enum { @@ -105,7 +120,7 @@ class ShelloutProcessing // we use strings rather than UCS2Strings for the scene name and parameters since the passed // parameters (via POVMS) are also strings. - ShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height); + ShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height); // you should reap any processes here as needed, and forcefully terminate ones still running. virtual ~ShelloutProcessing(); @@ -117,17 +132,17 @@ class ShelloutProcessing ShelloutAction::Action ReturnAction(shelloutEvent which) const { return shellouts[which]->ReturnAction(); } // return the command string as passed from the option parser; i.e. complete with parameters - string RawCommand(shelloutEvent which) const { return shellouts[which]->RawCommand(); } + std::string RawCommand(shelloutEvent which) const { return shellouts[which]->RawCommand(); } // the command itself, separated from its parameters. quotes around the command will have been removed. - string Command(shelloutEvent which) const { return shellouts[which]->Command(); } + std::string Command(shelloutEvent which) const { return shellouts[which]->Command(); } // the raw parameters after separation from the command. any quotes will remain in place. - string RawParameters(shelloutEvent which) const { return shellouts[which]->RawParameters(); } + std::string RawParameters(shelloutEvent which) const { return shellouts[which]->RawParameters(); } // the parameters after expansion of terms; e.g. %s to scene name. SetOutputFile() and // SetFrameClock() (if relevant) must be called prior to calling this method. - string Parameters(shelloutEvent which) const { return shellouts[which]->Parameters(); } + std::string Parameters(shelloutEvent which) const { return shellouts[which]->Parameters(); } // returns true if all frames should be skipped. if so, any subsequent calls for // pre-frame and post-frame actions will be ignored (and preferebly should not be @@ -145,7 +160,7 @@ class ShelloutProcessing int ExitCode(void) const { return exitCode; } // returns a string representation of the exit code; e.g. 'user abort' - string ExitDesc(void) const { return exitCode == 0 ? "SUCCESS" : exitCode == 2 ? "USER ABORT" : "FATAL ERROR"; } + std::string ExitDesc(void) const { return exitCode == 0 ? "SUCCESS" : exitCode == 2 ? "USER ABORT" : "FATAL ERROR"; } // returns true if the render should be halted. bool RenderCancelled(void) const { return cancelRender; } @@ -160,7 +175,7 @@ class ShelloutProcessing // if there is an output file, this method must be called prior to the pre-scene // action with the value of the first output file, and prior to pre-frame for each // subsequent output file if the render is an animation. - void SetOutputFile(const string& filename) { outputFile = filename; } + void SetOutputFile(const std::string& filename) { outputFile = filename; } // if the render is not an animation, there is no need to call SetFrameClock(). // if it is an animation, it must be called prior to the pre-scene action, and @@ -185,8 +200,8 @@ class ShelloutProcessing // 7: the command parameters (CAUTION: may contain escape codes) // 8: the command return code (as an integer) // 9: output text from the command, as returned by LastShelloutResult() - virtual string GetCancelMessage(void); - virtual void SetCancelMessage(const string& format) { cancelFormat.parse(format); } + virtual std::string GetCancelMessage(void); + virtual void SetCancelMessage(const std::string& format) { cancelFormat.parse(format); } // the positional parameters are as follows: // 1: the event causing the skip (as a string), e.g. "pre-scene" @@ -195,8 +210,8 @@ class ShelloutProcessing // 4: the command parameters (CAUTION: may contain escape codes) // 5: the command return code (as an integer) // 6: output text from the command, as returned by LastShelloutResult() - virtual string GetSkipMessage(void); - virtual void SetSkipMessage(const string& format) { skipFormat.parse(format); } + virtual std::string GetSkipMessage(void); + virtual void SetSkipMessage(const std::string& format) { skipFormat.parse(format); } // advise the code that a particular event should be handled now; e.g. pre-scene, post-scene // and so forth. this method should be called even if the platform indicates it does not @@ -218,7 +233,7 @@ class ShelloutProcessing // return the name of the currently running shellout (without parameters) // if no shellout is running, an empty string should be returned. - virtual string ProcessName(void) { return ShelloutRunning() ? runningProcessName : string(); } + virtual std::string ProcessName(void) { return ShelloutRunning() ? runningProcessName : std::string(); } // return the PID of the currently running shellout (or equivalent thereof). // returns 0 if no process is running, and -1 of the platform has no PID equivalent @@ -229,7 +244,7 @@ class ShelloutProcessing // in a form suitable for display on the console or UI message log - preferably // no more than a single line (width unimportant). if not implemented, an empty // string should be returned. - virtual string LastShelloutResult(void) { return string(); } + virtual std::string LastShelloutResult(void) { return std::string(); } // return true if this platform supports shellouts. virtual bool ShelloutsSupported(void) { return false; } @@ -252,25 +267,25 @@ class ShelloutProcessing unsigned int imageWidth; unsigned int imageHeight; float clockVal; - string sceneName; - string outputFile; - string runningProcessName; - string cancelPhase; - string cancelReason; - string cancelCommand; - string cancelParameters; - string cancelOutput; - string skipPhase; - string skipReason; - string skipCommand; - string skipParameters; - string skipOutput; + std::string sceneName; + std::string outputFile; + std::string runningProcessName; + std::string cancelPhase; + std::string cancelReason; + std::string cancelCommand; + std::string cancelParameters; + std::string cancelOutput; + std::string skipPhase; + std::string skipReason; + std::string skipCommand; + std::string skipParameters; + std::string skipOutput; boost::format cancelFormat; boost::format skipFormat; ShelloutPtr shellouts[lastShelloutEvent]; // helper method - string GetPhaseName(shelloutEvent event); + std::string GetPhaseName(shelloutEvent event); // execute the given command with the supplied parameters, which have already // been expanded as per the docs, and immediately return true without waiting @@ -291,7 +306,7 @@ class ShelloutProcessing // if the platform implemeting a subclass of this method has the equivalent of a // system log (e.g. syslog on unix, event log on windows), the implementation should // consider providing a user-controllable option to log any commands using such. - virtual bool ExecuteCommand(const string& cmd, const string& params); + virtual bool ExecuteCommand(const std::string& cmd, const std::string& params); // shutdown any currently-running shellouts. if force is true, force them to exit. // in either case, don't wait more than timeout milliseconds. return true if there @@ -312,13 +327,13 @@ class ShelloutProcessing // // if the platform does not support capturing output of processes (or the // processes are GUI-based), there is no requirement to return any output. - virtual int CollectCommand(string& output) { return -2; } + virtual int CollectCommand(std::string& output) { return -2; } virtual int CollectCommand(void) { return -2; } // return true if the requested shellout command is permitted. this method is // called just before a shellout runs. if it fails, an exception will generally // be thrown by the caller (the method itself should not throw an exception). - virtual bool CommandPermitted(const string& command, const string& parameters) { return true; } + virtual bool CommandPermitted(const std::string& command, const std::string& parameters) { return true; } // called by the internal parser during construction to separate commands from parameters. // given a raw string in the form returned from the POV INI file, extract the command and any parameters. @@ -340,16 +355,17 @@ class ShelloutProcessing // parameters start will not be removed. // // this method should return true if the command is non-empty upon completion. - virtual bool ExtractCommand(const string& src, string& command, string& parameters) const; + virtual bool ExtractCommand(const std::string& src, std::string& command, std::string& parameters) const; private: bool processStartRequested; shelloutEvent postProcessEvent; bool HandleProcessEvent(shelloutEvent which, bool internalCall); - bool PostProcessEvent(void); + bool PostProcessEvent(); }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_SHELLOUTPROCESSING_H diff --git a/source/frontend/simplefrontend.h b/source/frontend/simplefrontend.h index 65d2f0aed..e6fc7a3f8 100644 --- a/source/frontend/simplefrontend.h +++ b/source/frontend/simplefrontend.h @@ -39,17 +39,25 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" -#include +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/povassert.h" +#include "base/stringutilities.h" +#include "base/image/image_fwd.h" + +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (frontend module) #include "frontend/animationprocessing.h" #include "frontend/renderfrontend.h" #include "frontend/shelloutprocessing.h" -namespace pov_base -{ -class Image; -} - namespace pov_frontend { @@ -80,16 +88,16 @@ enum State }; template -class SimpleFrontend +class SimpleFrontend final { public: SimpleFrontend(POVMSContext ctx, POVMSAddress addr, POVMS_Object& msg, boost::function cfn, boost::function dfn, - POVMS_Object *result = nullptr, shared_ptr console = shared_ptr()); + POVMS_Object *result = nullptr, std::shared_ptr console = std::shared_ptr()); ~SimpleFrontend(); - bool Start(POVMS_Object& opts, shared_ptr img = shared_ptr()); + bool Start(POVMS_Object& opts, std::shared_ptr img = std::shared_ptr()); bool Stop(); bool Pause(); bool Resume(); @@ -98,9 +106,9 @@ class SimpleFrontend State GetState() const; - shared_ptr GetConsole(); - shared_ptr GetImage(); - shared_ptr GetDisplay(); + std::shared_ptr GetConsole(); + std::shared_ptr GetImage(); + std::shared_ptr GetDisplay(); private: RenderFrontend renderFrontend; POVMSAddress backendAddress; @@ -108,9 +116,9 @@ class SimpleFrontend POVMS_Object options; RenderFrontendBase::SceneId sceneId; RenderFrontendBase::ViewId viewId; - shared_ptr imageProcessing; - shared_ptr animationProcessing; - shared_ptr shelloutProcessing; + std::shared_ptr imageProcessing; + std::shared_ptr animationProcessing; + std::shared_ptr shelloutProcessing; boost::function createConsole; boost::function createDisplay; }; @@ -119,7 +127,7 @@ template SimpleFrontend::SimpleFrontend(POVMSContext ctx, POVMSAddress addr, POVMS_Object& msg, boost::function cfn, boost::function dfn, - POVMS_Object *result, shared_ptr console) : + POVMS_Object *result, std::shared_ptr console) : renderFrontend(ctx), backendAddress(addr), state(kReady), @@ -137,7 +145,7 @@ SimpleFrontend::~SimpleFrontend() } template -bool SimpleFrontend::Start(POVMS_Object& opts, shared_ptr img) +bool SimpleFrontend::Start(POVMS_Object& opts, std::shared_ptr img) { int width; int height; @@ -164,16 +172,16 @@ bool SimpleFrontend::Start(POVMS_Object opts.Set(kPOVAttrib_Declare, declares); if(opts.TryGetInt(kPOVAttrib_FinalFrame, 0) > 0) - animationProcessing = shared_ptr(new AnimationProcessing(opts)); + animationProcessing = std::shared_ptr(new AnimationProcessing(opts)); options = opts; if(opts.TryGetBool(kPOVAttrib_OutputToFile, true)) { if (img != nullptr) - imageProcessing = shared_ptr(new ImageProcessing(img)); + imageProcessing = std::shared_ptr(new ImageProcessing(img)); else - imageProcessing = shared_ptr(new ImageProcessing(options)); + imageProcessing = std::shared_ptr(new ImageProcessing(options)); } Path ip (opts.TryGetString(kPOVAttrib_InputFile, "")); @@ -453,23 +461,24 @@ State SimpleFrontend::GetState() const } template -shared_ptr SimpleFrontend::GetConsole() +std::shared_ptr SimpleFrontend::GetConsole() { return renderFrontend.GetConsole(sceneId); } template -shared_ptr SimpleFrontend::GetImage() +std::shared_ptr SimpleFrontend::GetImage() { return renderFrontend.GetImage(viewId); } template -shared_ptr SimpleFrontend::GetDisplay() +std::shared_ptr SimpleFrontend::GetDisplay() { return renderFrontend.GetDisplay(viewId); } } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_SIMPLEFRONTEND_H diff --git a/source/parser/configparser.h b/source/parser/configparser.h index c81729c54..c89a7c8f6 100644 --- a/source/parser/configparser.h +++ b/source/parser/configparser.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,6 +38,7 @@ #ifndef POVRAY_PARSER_CONFIGPARSER_H #define POVRAY_PARSER_CONFIGPARSER_H +// Pull in other compile-time config header files first #include "core/configcore.h" #include "syspovconfigparser.h" diff --git a/source/parser/fncode.cpp b/source/parser/fncode.cpp index 9032dda71..41fe13e26 100644 --- a/source/parser/fncode.cpp +++ b/source/parser/fncode.cpp @@ -38,19 +38,27 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/fncode.h" +// C++ variants of C standard header files #include #include #include + +// C++ standard header files #include // POV-Ray header files (base module) +#include "base/pov_mem.h" +#include "base/povassert.h" #include "base/stringutilities.h" +// POV-Ray header files (core module) #include "core/scene/scenedata.h" +// POV-Ray header files (VM module) #include "vm/fnintern.h" #include "vm/fnpovfpu.h" +// POV-Ray header files (parser module) #include "parser/parser.h" // this must be the last header file included @@ -59,6 +67,9 @@ namespace pov_parser { +using std::min; +using std::max; + using namespace pov; /***************************************************************************** @@ -2236,6 +2247,7 @@ void FNCode::disassemble_instruction(FILE *f, Instruction& i) #include "fnasm.cpp" -#endif +#endif // DEBUG_FLOATFUNCTION } +// end of namespace pov_parser diff --git a/source/parser/fncode.h b/source/parser/fncode.h index ab0792eaa..0b4d2bdbb 100644 --- a/source/parser/fncode.h +++ b/source/parser/fncode.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,16 +41,23 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "parser/configparser.h" -#include "vm/fnpovfpu.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) -#include "parser/reservedwords.h" +// Boost header files +#include -namespace pov -{ +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) -class FunctionVM; +// POV-Ray header files (VM module) +#include "vm/fnpovfpu_fwd.h" -} +// POV-Ray header files (parser module) +#include "parser/parser_fwd.h" +#include "parser/reservedwords.h" namespace pov_parser { @@ -96,11 +103,9 @@ enum OP_TRAP // 23 }; -class Parser; - void FNCode_Copy(FunctionCode *, FunctionCode *); -struct ExprNode +struct ExprNode final { ExprNode *parent; ExprNode *child; @@ -122,7 +127,7 @@ struct ExprNode }; }; -class FNCode +class FNCode final { public: FNCode(Parser *, FunctionCode *, bool, const char *); @@ -137,7 +142,7 @@ class FNCode private: FunctionCode *function; Parser *parser; - intrusive_ptr functionVM; + boost::intrusive_ptr functionVM; unsigned int max_program_size; unsigned int max_stack_size; @@ -153,8 +158,8 @@ class FNCode #endif - FNCode(); - FNCode(FNCode&); + FNCode() = delete; + FNCode(FNCode&) = delete; void compile_recursive(ExprNode *expr); void compile_member(char *name); @@ -191,5 +196,6 @@ class FNCode }; } +// end of namespace pov_parser #endif // POVRAY_PARSER_FNCODE_H diff --git a/source/parser/parser.cpp b/source/parser/parser.cpp index 4dbeb5a0b..27e4c0c36 100644 --- a/source/parser/parser.cpp +++ b/source/parser/parser.cpp @@ -48,11 +48,16 @@ // Boost header files #include -#include // POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/fileutil.h" +#include "base/path.h" +#include "base/povassert.h" +#include "base/stringutilities.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/image.h" // POV-Ray header files (core module) #include "core/bounding/boundingcylinder.h" @@ -108,6 +113,9 @@ // POV-Ray header files (VM module) #include "vm/fnpovfpu.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -116,6 +124,11 @@ namespace pov_parser using namespace pov; +using std::min; +using std::max; +using std::shared_ptr; +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -125,23 +138,7 @@ using namespace pov; const DBL INFINITE_VOLUME = BOUND_HUGE; -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** Parser::Parser(shared_ptr sd, const Options& opts, GenericMessenger& mf, FileResolver& fr, ProgressReporter& pr, TraceThreadData& td) : @@ -176,7 +173,7 @@ Parser::~Parser() /* Parse the file. */ void Parser::Run() { - SourceInfo errorInfo(UCS2String(POV_FILENAME_BUFFER_CHARS, 0), // Pre-claim some memory, so we can handle an out-of-memory error. + SourceInfo errorInfo(UCS2String(POV_FILENAME_BUFFER_CHARS, u'\0'), // Pre-claim some memory, so we can handle an out-of-memory error. SourcePosition(-1,-1,-1)); // Outer try/catch block to handle out-of-memory conditions @@ -216,7 +213,7 @@ void Parser::Run() if(i->second[0] == '\"') { - string tmp(i->second, 1, i->second.length() - 2); + std::string tmp(i->second, 1, i->second.length() - 2); Temp_Entry = mSymbolStack.GetGlobalTable()->Add_Symbol(i->first, STRING_ID_TOKEN); Temp_Entry->Data = String_Literal_To_UCS2(tmp); } @@ -515,24 +512,7 @@ void Parser::Finish() Cleanup(); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** /* Set up the fields in the frame to default values. */ void Parser::Frame_Init() @@ -551,8 +531,7 @@ void Parser::Frame_Init() sceneData->skysphere = nullptr; } - -/****************************************************************************/ +//****************************************************************************** void Parser::InitDefaults(int version) { @@ -619,24 +598,7 @@ void Parser::InitDefaults(int version) defaultsVersion = newDefaults; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Destroy_Frame() { @@ -699,24 +661,7 @@ void Parser::Destroy_Frame() } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** bool Parser::Parse_Begin (TokenId tokenId, bool mandatory) { @@ -738,24 +683,7 @@ bool Parser::Parse_Begin (TokenId tokenId, bool mandatory) } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_End(TokenId openTokenId, TokenId expectTokenId) { @@ -781,23 +709,7 @@ void Parser::Parse_End(TokenId openTokenId, TokenId expectTokenId) Error("No matching %s, %s found instead", Get_Token_String(expectTokenId), Get_Token_String(CurrentTrueTokenId())); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Bicubic_Patch () { @@ -1219,25 +1131,7 @@ void Parser::Parse_Blob_Element_Mods(Blob_Element *Element) Post_Textures(Element->Texture); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Box () { @@ -1425,23 +1319,7 @@ void Parser::Parse_User_Defined_Camera (Camera& Cam) END_EXPECT } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Camera (Camera& Cam) { @@ -2303,24 +2181,7 @@ bool Parser::Parse_Camera_Mods(Camera& New) return true; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_CSG(int CSG_Type) { @@ -2378,23 +2239,7 @@ ObjectPtr Parser::Parse_CSG(int CSG_Type) return (reinterpret_cast(Object)); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Cone () { @@ -2427,24 +2272,7 @@ ObjectPtr Parser::Parse_Cone () return (reinterpret_cast(Object)); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Cylinder () { @@ -2476,24 +2304,7 @@ ObjectPtr Parser::Parse_Cylinder () return (reinterpret_cast(Object)); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Disc () { @@ -2537,25 +2348,7 @@ ObjectPtr Parser::Parse_Disc () return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_HField () { @@ -3191,23 +2984,7 @@ ObjectPtr Parser::Parse_Lathe() return (reinterpret_cast(Object)); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Lemon () { @@ -3432,25 +3209,7 @@ ObjectPtr Parser::Parse_Light_Group() return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Light_Source () { @@ -5204,24 +4963,7 @@ ObjectPtr Parser::Parse_Parametric(void) return (reinterpret_cast(Object)); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Plane () { @@ -5252,25 +4994,7 @@ ObjectPtr Parser::Parse_Plane () return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Poly (int order) { @@ -5300,23 +5024,7 @@ ObjectPtr Parser::Parse_Poly (int order) return (reinterpret_cast(Object)); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Polynom () { @@ -5785,25 +5493,7 @@ ObjectPtr Parser::Parse_Prism() return(reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Quadric () { @@ -5833,25 +5523,7 @@ ObjectPtr Parser::Parse_Quadric () return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Smooth_Triangle () { @@ -6027,25 +5699,7 @@ ObjectPtr Parser::Parse_Sor() return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Sphere() { @@ -6353,25 +6007,7 @@ ObjectPtr Parser::Parse_Torus() return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Triangle() { @@ -6401,25 +6037,7 @@ ObjectPtr Parser::Parse_Triangle() return(reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_TrueType () { @@ -6634,24 +6252,7 @@ TrueTypeFont *Parser::OpenFontFile(const char *asciifn, const int font_id, POV_U return font; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Object () { @@ -6849,25 +6450,7 @@ ObjectPtr Parser::Parse_Object () return Object; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Default () { @@ -6952,25 +6535,7 @@ void Parser::Parse_Default () Not_In_Default = true; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Frame () { @@ -7115,33 +6680,15 @@ void Parser::Parse_Frame () END_EXPECT } +//****************************************************************************** - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ - -void Parser::Parse_Global_Settings() -{ - Parse_Begin(); - EXPECT - CASE (IRID_WAVELENGTH_TOKEN) - Parse_Wavelengths (sceneData->iridWavelengths); - END_CASE +void Parser::Parse_Global_Settings() +{ + Parse_Begin(); + EXPECT + CASE (IRID_WAVELENGTH_TOKEN) + Parse_Wavelengths (sceneData->iridWavelengths); + END_CASE CASE (CHARSET_TOKEN) Warning("Encountered 'charset' global setting. As of POV-Ray v3.8, this mechanism " @@ -7620,25 +7167,7 @@ void Parser::Parse_Global_Settings() Parse_End(); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** // be aware that this method may change the address of Object // (this will only happen if Object is CSG and the invert_object keyword is parsed) @@ -8100,25 +7629,7 @@ ObjectPtr Parser::Parse_Object_Mods (ObjectPtr Object) return Object; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Matrix(MATRIX Matrix) { @@ -8151,25 +7662,7 @@ void Parser::Parse_Matrix(MATRIX Matrix) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** TRANSFORM *Parser::Parse_Transform(TRANSFORM *Trans) { @@ -8194,23 +7687,8 @@ TRANSFORM *Parser::Parse_Transform(TRANSFORM *Trans) } return Trans; } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ + +//****************************************************************************** TRANSFORM *Parser::Parse_Transform_Block(TRANSFORM *New) { @@ -8282,25 +7760,7 @@ TRANSFORM *Parser::Parse_Transform_Block(TRANSFORM *New) return (New); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Bound_Clip(vector& dest, bool notexture) { @@ -8420,24 +7880,7 @@ bool Parser::Parse_Three_UVCoords(Vector2d& UV1, Vector2d& UV2, Vector2d& UV3) } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** bool Parser::Parse_Comma (void) { @@ -8472,24 +7915,7 @@ bool Parser::Peek_Token (TokenId tokenId) return tokenMatches; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Semi_Colon (bool force_semicolon) { @@ -8510,25 +7936,7 @@ void Parser::Parse_Semi_Colon (bool force_semicolon) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Coeffs(int order, DBL *Coeffs) { @@ -8546,24 +7954,7 @@ void Parser::Parse_Coeffs(int order, DBL *Coeffs) Parse_Angle_End(); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Object_Id () { @@ -8579,24 +7970,7 @@ ObjectPtr Parser::Parse_Object_Id () return (Object); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Declare(bool is_local, bool after_hash) { @@ -9458,49 +8832,14 @@ bool Parser::Parse_RValue (TokenId Previous, TokenId *NumberPtr, void **DataPtr, return(Found); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Link(ObjectPtr New_Object, vector& Object_List_Root) { Object_List_Root.push_back(New_Object); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Link_Textures (TEXTURE **Old_Textures, TEXTURE *New_Textures) { @@ -9586,48 +8925,14 @@ void Parser::Test_Redefine(TokenId Previous, TokenId *NumberPtr, void *Data, boo } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Error(TokenId Token_Id) { Expectation_Error(Get_Token_String(Token_Id)); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Found_Instead_Error(const char *exstr, const char *extokstr) { @@ -9656,24 +8961,7 @@ void Parser::Found_Instead_Error(const char *exstr, const char *extokstr) } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Warn_State(TokenId Type) { @@ -9693,50 +8981,14 @@ void Parser::Warn_State(TokenId Type) POV_FREE(str); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::MAError (const char *, long) { throw std::bad_alloc(); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Post_Process (ObjectPtr Object, ObjectPtr Parent) { @@ -10179,50 +9431,14 @@ void Parser::Link_To_Frame(ObjectPtr Object) Destroy_Object(Object); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Only_In(const char *s1, const char *s2) { Error("Keyword '%s' can only be used in a %s statement.",s1,s2); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Not_With(const char *s1, const char *s2) { @@ -10354,25 +9570,7 @@ void Parser::Set_CSG_Tree_Flag(ObjectPtr Object, unsigned int f, int val) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** /* NK layers - 1999 June 10 - for backwards compatibility with layered textures */ void Parser::Convert_Filter_To_Transmit(PIGMENT *Pigment) @@ -10418,24 +9616,7 @@ void Parser::Convert_Filter_To_Transmit(GenericPigmentBlendMap *pBlendMap) POV_BLEND_MAP_ASSERT(false); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Expectation_Error(const char *s) { @@ -10770,16 +9951,16 @@ shared_ptr Parser::Locate_File(const UCS2String& filename, unsigned int } */ -/*****************************************************************************/ +//****************************************************************************** OStream *Parser::CreateFile(const UCS2String& filename, unsigned int stype, bool append) { return mFileResolver.CreateFile(filename, stype, append); } -/*****************************************************************************/ +//****************************************************************************** -Image *Parser::Read_Image(int filetype, const UCS2 *filename, const Image::ReadOptions& options) +Image *Parser::Read_Image(int filetype, const UCS2 *filename, const ImageReadOptions& options) { unsigned int stype; Image::ImageFileType type; @@ -10851,14 +10032,14 @@ Image *Parser::Read_Image(int filetype, const UCS2 *filename, const Image::ReadO return Image::Read(type, file.get(), options); } -/*****************************************************************************/ +//****************************************************************************** RGBFTColour *Parser::Create_Colour () { return new RGBFTColour(); } -/*****************************************************************************/ +//****************************************************************************** bool Parser::POV_ARRAY::IsInitialized() const { @@ -10966,6 +10147,31 @@ Parser::POV_ARRAY* Parser::POV_ARRAY::Clone() const return new POV_ARRAY(*this); } -/*****************************************************************************/ +//****************************************************************************** + +Parser::AssignableFunction::AssignableFunction(const AssignableFunction& obj) : + fn(obj.vm->CopyFunction(obj.fn)), + vm(obj.vm) +{} + +Parser::AssignableFunction::AssignableFunction(FUNCTION_PTR fn, boost::intrusive_ptr vm) : + fn(fn), + vm(vm) +{} + +Parser::AssignableFunction::~AssignableFunction() +{ + vm->DestroyFunction(fn); +} + +//****************************************************************************** + +UCS2String Parser::BraceStackEntry::GetFileName() const +{ + return file->Name(); +} -} // end of namespace +//****************************************************************************** + +} +// end of namespace pov_parser diff --git a/source/parser/parser.h b/source/parser/parser.h index a882ec5bf..1353e9ff6 100644 --- a/source/parser/parser.h +++ b/source/parser/parser.h @@ -40,20 +40,40 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "parser/configparser.h" +#include "parser/parser_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +#include + +// Boost headers +#include -#include "base/image/image.h" -#include "base/messenger.h" -#include "base/stringutilities.h" -#include "base/textstream.h" +// POV-Ray header files (base module) +#include "base/base_fwd.h" +#include "base/messenger_fwd.h" +#include "base/povassert.h" +#include "base/stringtypes.h" +#include "base/textstream_fwd.h" #include "base/textstreambuffer.h" +#include "base/image/image_fwd.h" +// POV-Ray header files (core module) +#include "core/core_fwd.h" #include "core/material/blendmap.h" #include "core/material/pigment.h" #include "core/material/warp.h" +#include "core/scene/atmosphere_fwd.h" #include "core/scene/camera.h" +// POV-Ray header files (VM module) +#include "vm/fnpovfpu_fwd.h" + +// POV-Ray header files (parser module) #include "parser/fncode.h" #include "parser/parsertypes.h" #include "parser/reservedwords.h" @@ -65,18 +85,15 @@ namespace pov class Blob_Element; struct ContainedByShape; -struct Fog_Struct; struct GenericSpline; class ImageData; class Mesh; struct PavementPattern; -struct Rainbow_Struct; -class SceneData; -struct Skysphere_Struct; struct TilingPattern; struct TrueTypeFont; } +// end of namespace pov namespace pov_parser { @@ -155,7 +172,7 @@ const int TOKEN_OVERFLOW_RESET_COUNT = 2500; } -struct ExperimentalFlags +struct ExperimentalFlags final { bool backsideIllumination : 1; bool functionHf : 1; @@ -180,7 +197,7 @@ struct ExperimentalFlags {} }; -struct BetaFlags +struct BetaFlags final { bool realTimeRaytracing : 1; bool videoCapture : 1; @@ -195,34 +212,20 @@ struct BetaFlags * Global typedefs ******************************************************************************/ -class Parser +class Parser final { public: using Options = ParserOptions; - struct FileResolver - { - virtual ~FileResolver() {} - virtual UCS2String FindFile(UCS2String parsedFileName, unsigned int fileType) = 0; - virtual IStream* ReadFile(const UCS2String& parsedFileName, const UCS2String& foundFileName, unsigned int fileType) = 0; - virtual OStream* CreateFile(const UCS2String& parsedFileName, unsigned int fileType, bool append) = 0; - }; - - struct ProgressReporter - { - virtual ~ProgressReporter() {} - virtual void ReportProgress(POV_LONG tokenCount) = 0; - }; - - class DebugTextStreamBuffer : public TextStreamBuffer + class DebugTextStreamBuffer final : public TextStreamBuffer { public: DebugTextStreamBuffer(GenericMessenger& m); - ~DebugTextStreamBuffer(); + virtual ~DebugTextStreamBuffer() override; protected: - virtual void lineoutput(const char *str, unsigned int chars); - virtual void directoutput(const char *str, unsigned int chars); + virtual void lineoutput(const char *str, unsigned int chars) override; + virtual void directoutput(const char *str, unsigned int chars) override; GenericMessenger& mMessenger; }; @@ -230,7 +233,7 @@ class Parser // tokenize.h/tokenize.cpp /// Structure holding information about the current token - struct Token_Struct : MessageContext + struct Token_Struct final : MessageContext { RawToken raw; ConstStreamPtr sourceFile; @@ -256,7 +259,7 @@ class Parser /// Token category if applicable, otherwise equal to @ref mTrueTokenId. TokenId GetCategorizedTokenId() const; - virtual UCS2String GetFileName() const override { return sourceFile->Name(); } + virtual UCS2String GetFileName() const override; virtual POV_LONG GetLine() const override { return raw.lexeme.position.line; } virtual POV_LONG GetColumn() const override { return raw.lexeme.position.column; } virtual POV_OFF_T GetOffset() const override { return raw.lexeme.position.offset; } @@ -267,7 +270,7 @@ class Parser TokenId mCategorizedTokenId; ///< Token category if applicable, otherwise equal to @ref mTrueTokenId. }; - struct LValue + struct LValue final { TokenId* numberPtr; void** dataPtr; @@ -277,34 +280,34 @@ class Parser bool optional : 1; }; - struct MacroParameter + struct MacroParameter final { char* name; bool optional; }; - struct Macro : public Assignable + struct Macro final : public Assignable { Macro(const char *); - virtual ~Macro(); + virtual ~Macro() override; virtual Macro* Clone() const override { POV_PARSER_PANIC(); return nullptr; } char *Macro_Name; RawTokenizer::ColdBookmark source; LexemePosition endPosition; ///< The position _after_ the `#` in the terminating `#end` directive. - vector parameters; + std::vector parameters; unsigned char *Cache; size_t CacheSize; }; - struct POV_ARRAY : public Assignable + struct POV_ARRAY final : public Assignable { static const int kMaxDimensions = 5; int maxDim; ///< Index of highest dimension. TokenId Type_; int Sizes[kMaxDimensions]; size_t Mags[kMaxDimensions]; - vector DataPtrs; - vector Types; + std::vector DataPtrs; + std::vector Types; bool resizable : 1; bool mixedType : 1; bool IsInitialized() const; @@ -318,21 +321,21 @@ class Parser void Shrink(); POV_ARRAY() = default; POV_ARRAY(const POV_ARRAY& obj); - virtual ~POV_ARRAY(); + virtual ~POV_ARRAY() override; virtual POV_ARRAY* Clone() const override; }; - struct POV_PARAM + struct POV_PARAM final { TokenId *NumberPtr; void **DataPtr; }; - struct DATA_FILE : public Assignable + struct DATA_FILE final : public Assignable { - shared_ptr inTokenizer; - RawToken inToken; - shared_ptr Out_File; + std::shared_ptr inTokenizer; + RawToken inToken; + std::shared_ptr Out_File; bool inUngetToken : 1; bool busyParsing : 1; ///< `true` if parsing a statement related to the file, `false` otherwise. @@ -359,18 +362,18 @@ class Parser }; /// @todo Refactor code to use @ref FunctionVM::CustomFunction instead. - struct AssignableFunction : public Assignable + struct AssignableFunction final : public Assignable { - FUNCTION_PTR fn; - intrusive_ptr vm; - AssignableFunction(const AssignableFunction& obj) : fn(obj.vm->CopyFunction(obj.fn)), vm(obj.vm) {} - AssignableFunction(FUNCTION_PTR fn, intrusive_ptr vm) : fn(fn), vm(vm) {} - virtual ~AssignableFunction() { vm->DestroyFunction(fn); } + FUNCTION_PTR fn; + boost::intrusive_ptr vm; + AssignableFunction(const AssignableFunction& obj); + AssignableFunction(FUNCTION_PTR fn, boost::intrusive_ptr vm); + virtual ~AssignableFunction() override; virtual AssignableFunction* Clone() const override { return new AssignableFunction(*this); } }; // constructor - Parser(shared_ptr sd, const Options& opts, + Parser(std::shared_ptr sd, const Options& opts, GenericMessenger& mf, FileResolver& fnr, ProgressReporter& pr, TraceThreadData& td); ~Parser(); @@ -419,7 +422,7 @@ class Parser ObjectPtr Parse_Object_Mods (ObjectPtr Object); ObjectPtr Parse_Object (void); - void Parse_Bound_Clip (vector& objects, bool notexture = true); + void Parse_Bound_Clip (std::vector& objects, bool notexture = true); void Parse_Default (void); void Parse_Declare (bool is_local, bool after_hash); void Parse_Matrix (MATRIX Matrix); @@ -452,10 +455,10 @@ class Parser /// @param[in] formalFileName Name by which the file is known to the user. /// @param[out] actualFileName Name by which the file is known to the parsing computer. - shared_ptr Locate_File(const UCS2String& formalFileName, unsigned int stype, UCS2String& actualFileName, bool err_flag = false); + std::shared_ptr Locate_File(const UCS2String& formalFileName, unsigned int stype, UCS2String& actualFileName, bool err_flag = false); OStream *CreateFile(const UCS2String& filename, unsigned int stype, bool append); - Image *Read_Image(int filetype, const UCS2 *filename, const Image::ReadOptions& options); + Image *Read_Image(int filetype, const UCS2 *filename, const ImageReadOptions& options); // tokenize.h/tokenize.cpp void Get_Token (void); @@ -486,7 +489,7 @@ class Parser const LexemePosition& CurrentFilePosition() const; bool HaveCurrentMessageContext() const; const MessageContext& CurrentMessageContext() const; - void SetInputStream(const shared_ptr& stream); + void SetInputStream(const std::shared_ptr& stream); RawTokenizer::HotBookmark GetHotBookmark(); bool GoToBookmark(const RawTokenizer::HotBookmark& bookmark); @@ -512,10 +515,10 @@ class Parser void Parse_Pigment (PIGMENT **); void Parse_Tnormal (TNORMAL **); void Parse_Finish (FINISH **); - void Parse_Media (vector&); + void Parse_Media (std::vector&); void Parse_Interior (InteriorPtr&); void Parse_Media_Density_Pattern (PIGMENT **); - void Parse_Media_Density_Pattern (vector&); + void Parse_Media_Density_Pattern (std::vector&); Fog_Struct *Parse_Fog (void); Rainbow_Struct *Parse_Rainbow (void); Skysphere_Struct *Parse_Skysphere(void); @@ -531,12 +534,12 @@ class Parser void Parse_Colour (MathColour& colour); void Parse_Wavelengths (MathColour& colour); template void Parse_BlendMapData (BlendMapTypeId Blend_Type, DATA_T& rData); - template shared_ptr Parse_Blend_Map (BlendMapTypeId Blend_Type, int Pat_Type); - template shared_ptr Parse_Colour_Map (void); + template std::shared_ptr Parse_Blend_Map (BlendMapTypeId Blend_Type, int Pat_Type); + template std::shared_ptr Parse_Colour_Map (void); template void Parse_BlendListData (BlendMapTypeId Blend_Type, DATA_T& rData); template void Parse_BlendListData_Default (const ColourBlendMapData& Def_Entry, BlendMapTypeId Blend_Type, DATA_T& rData); - template shared_ptr Parse_Blend_List (int Count, ColourBlendMapConstPtr Def_Map, BlendMapTypeId Blend_Type); - template shared_ptr Parse_Item_Into_Blend_List (BlendMapTypeId Blend_Type); + template std::shared_ptr Parse_Blend_List (int Count, ColourBlendMapConstPtr Def_Map, BlendMapTypeId Blend_Type); + template std::shared_ptr Parse_Item_Into_Blend_List (BlendMapTypeId Blend_Type); GenericSpline *Parse_Spline (void); /// Parses a FLOAT. @@ -574,7 +577,7 @@ class Parser FUNCTION_PTR Parse_FunctionOrContent(void); void Parse_FunctionOrContentList(GenericScalarFunctionPtr* apFn, unsigned int count, bool mandatory = true); FUNCTION_PTR Parse_DeclareFunction(TokenId *token_id, const char *fn_name, bool is_local); - intrusive_ptr GetFunctionVM() const; + boost::intrusive_ptr GetFunctionVM() const; // parsestr.h/parsestr.cpp char *Parse_C_String(bool pathname = false); @@ -587,7 +590,6 @@ class Parser char *UCS2_To_String(const UCS2 *str); static UCS2 *UCS2_strcat(UCS2 *s1, const UCS2 *s2); - static int UCS2_strcmp(const UCS2 *s1, const UCS2 *s2); static void UCS2_strcpy(UCS2 *s1, const UCS2 *s2); static void UCS2_strncpy(UCS2 *s1, const UCS2 *s2, int n); void UCS2_strupr(UCS2 *str); // not static because it may issue a parse warning @@ -603,7 +605,7 @@ class Parser bool expr_ret(ExprNode *¤t, int stage, int op); bool expr_err(ExprNode *¤t, int stage, int op); - shared_ptr sceneData; + std::shared_ptr sceneData; private: @@ -616,19 +618,19 @@ class Parser Token_Struct mToken; - struct BraceStackEntry : LexemePosition, MessageContext + struct BraceStackEntry final : LexemePosition, MessageContext { TokenId openToken; ConstStreamPtr file; BraceStackEntry(const Token_Struct& token) : LexemePosition(token.raw.lexeme.position), openToken(token.GetTrueTokenId()), file(token.sourceFile) {} - virtual UCS2String GetFileName() const override { return file->Name(); } + virtual UCS2String GetFileName() const override; virtual POV_LONG GetLine() const override { return line; } virtual POV_LONG GetColumn() const override { return column; } virtual POV_OFF_T GetOffset() const override { return offset; } }; - intrusive_ptr mpFunctionVM; + boost::intrusive_ptr mpFunctionVM; FPUContext *fnVMContext; bool Had_Max_Trace_Level; @@ -648,7 +650,7 @@ class Parser /// true if a #version statement is being parsed bool parsingVersionDirective; - vector maBraceStack; + std::vector maBraceStack; bool Destroying_Frame; Camera Default_Camera; @@ -676,7 +678,7 @@ class Parser POV_LONG mTokenCount; int mTokensSinceLastProgressReport; - struct IncludeStackEntry + struct IncludeStackEntry final { RawTokenizer::HotBookmark returnToBookmark; int condStackSize; @@ -686,9 +688,9 @@ class Parser returnToBookmark(rtb), condStackSize(css), braceStackSize(bss) {} }; - vector maIncludeStack; + std::vector maIncludeStack; - struct CS_ENTRY + struct CS_ENTRY final { COND_TYPE Cond_Type; DBL Switch_Value; @@ -703,7 +705,7 @@ class Parser ~CS_ENTRY() {} }; - vector Cond_Stack; + std::vector Cond_Stack; bool Skipping, Inside_Ifdef, Inside_MacroDef, Parsing_Directive, parseRawIdentifiers, parseOptionalRValue; bool Got_EOF; // WARNING: Changes to the use of this variable are very dangerous as it is used in many places assuming certain non-obvious side effects! [trf] @@ -789,7 +791,7 @@ class Parser bool Parse_Camera_Mods(Camera& Cam); void Parse_Frame(); - void Link(ObjectPtr New_Object, vector& Object_List_Root); + void Link(ObjectPtr New_Object, std::vector& Object_List_Root); void Link_To_Frame(ObjectPtr Object); void Post_Process(ObjectPtr Object, ObjectPtr Parent); @@ -801,7 +803,7 @@ class Parser ObjectPtr Parse_Isosurface(); ObjectPtr Parse_Parametric(); - void ParseContainedBy(shared_ptr& container, ObjectPtr obj); + void ParseContainedBy(std::shared_ptr& container, ObjectPtr obj); ObjectPtr Parse_Sphere_Sweep(void); bool Parse_Three_UVCoords(Vector2d& UV1, Vector2d& UV2, Vector2d& UV3); @@ -844,8 +846,8 @@ class Parser PatternPtr ParsePotentialPattern(); PatternPtr ParseSlopePattern(); template PatternPtr ParseSpiralPattern(); - void VerifyPavementPattern(shared_ptr pattern); - void VerifyTilingPattern(shared_ptr pattern); + void VerifyPavementPattern(std::shared_ptr pattern); + void VerifyTilingPattern(std::shared_ptr pattern); void VerifyPattern(PatternPtr pattern); void Parse_Bump_Map (TNORMAL *Tnormal); void Parse_Image_Map (PIGMENT *Pigment); @@ -931,5 +933,6 @@ class Parser }; } +// end of namespace pov_parser #endif // POVRAY_PARSER_PARSE_H diff --git a/source/parser/parser_expressions.cpp b/source/parser/parser_expressions.cpp index 96cfb3b9e..357c7e3f6 100644 --- a/source/parser/parser_expressions.cpp +++ b/source/parser/parser_expressions.cpp @@ -38,6 +38,7 @@ // C++ variants of C standard header files #include +#include #include // C++ standard header files @@ -49,7 +50,9 @@ // POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/mathutil.h" +#include "base/pov_mem.h" #include "base/stringutilities.h" +#include "base/image/colourspace.h" // POV-Ray header files (core module) #include "core/material/blendmap.h" @@ -71,6 +74,9 @@ // POV-Ray header files (VM module) #include "vm/fnpovfpu.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -80,30 +86,17 @@ namespace pov_parser using namespace pov_base; using namespace pov; +using std::min; +using std::max; +using std::shared_ptr; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ #define FTRUE(f) ((int)(fabs(f)>EPSILON)) - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** DBL Parser::Parse_Float_Param() { @@ -131,25 +124,7 @@ DBL Parser::Parse_Float_Param() return (Local); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Float_Param2(DBL *Val1,DBL *Val2) { @@ -165,25 +140,7 @@ void Parser::Parse_Float_Param2(DBL *Val1,DBL *Val2) Allow_Identifier_In_Call = old_allow_id; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Vector_Param(Vector3d& Vector) { @@ -192,25 +149,7 @@ void Parser::Parse_Vector_Param(Vector3d& Vector) Parse_Paren_End(); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Vector_Param2(Vector3d& Val1, Vector3d& Val2) { @@ -221,23 +160,7 @@ void Parser::Parse_Vector_Param2(Vector3d& Val1, Vector3d& Val2) Parse_Paren_End(); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Trace(Vector3d& Res) { @@ -285,23 +208,7 @@ void Parser::Parse_Trace(Vector3d& Res) Parse_Paren_End(); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** int Parser::Parse_Inside() { @@ -606,23 +513,7 @@ void Parser::Parse_Spline_Call(EXPRESS& Express, int *Terms) } } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) { @@ -735,15 +626,15 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) break; case ACOSH_TOKEN: - Val = acosh(Parse_Float_Param()); + Val = std::acosh(Parse_Float_Param()); break; case ASINH_TOKEN: - Val = asinh(Parse_Float_Param()); + Val = std::asinh(Parse_Float_Param()); break; case ATANH_TOKEN: - Val = atanh(Parse_Float_Param()); + Val = std::atanh(Parse_Float_Param()); break; case CEIL_TOKEN: @@ -1445,25 +1336,7 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** /* Promote_Express promotes Express to the requested number of terms. If *Old_Terms==1, then it sets all terms to Express[0]. Otherwise, it pads @@ -1640,24 +1513,7 @@ void Parser::Parse_Rel_Factor (EXPRESS& Express,int *Terms) } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** DBL Parser::Parse_Rel_String_Term (const UCS2 *lhs) { @@ -1721,23 +1577,7 @@ DBL Parser::Parse_Rel_String_Term (const UCS2 *lhs) END_EXPECT } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Rel_Term (EXPRESS& Express,int *Terms) { @@ -1821,25 +1661,7 @@ void Parser::Parse_Rel_Term (EXPRESS& Express,int *Terms) } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Logical (EXPRESS& Express,int *Terms) { @@ -1874,25 +1696,7 @@ void Parser::Parse_Logical (EXPRESS& Express,int *Terms) } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Express (EXPRESS& Express,int *Terms) { @@ -1928,25 +1732,7 @@ void Parser::Parse_Express (EXPRESS& Express,int *Terms) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** DBL Parser::Parse_Float () { @@ -2028,25 +1814,7 @@ bool Parser::Parse_Bool(const char* parameterName) return value; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** DBL Parser::Allow_Float (DBL defval) { @@ -2066,24 +1834,7 @@ DBL Parser::Allow_Float (DBL defval) return (retval); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** int Parser::Allow_Vector (Vector3d& Vect) { @@ -2104,25 +1855,7 @@ int Parser::Allow_Vector (Vector3d& Vect) return (retval); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Vector (Vector3d& Vector) { @@ -2154,24 +1887,7 @@ void Parser::Parse_Vector (Vector3d& Vector) Allow_Identifier_In_Call = old_allow_id; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Vector4D (VECTOR_4D Vector) { @@ -2203,26 +1919,7 @@ void Parser::Parse_Vector4D (VECTOR_4D Vector) Allow_Identifier_In_Call = old_allow_id; } - - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_UV_Vect (Vector2d& UV_Vect) { @@ -2254,25 +1951,7 @@ void Parser::Parse_UV_Vect (Vector2d& UV_Vect) Allow_Identifier_In_Call = old_allow_id; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** int Parser::Parse_Unknown_Vector(EXPRESS& Express, bool allow_identifier, bool *had_identifier) { @@ -2302,24 +1981,7 @@ int Parser::Parse_Unknown_Vector(EXPRESS& Express, bool allow_identifier, bool * return(Terms); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Scale_Vector (Vector3d& Vector) { @@ -2342,25 +2004,7 @@ void Parser::Parse_Scale_Vector (Vector3d& Vector) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Colour (RGBFTColour& colour, bool expectFT) { @@ -2856,7 +2500,7 @@ shared_ptr Parser::Parse_Blend_Map (BlendMapTypeId Blend_Type,int Pat_Typ Error ("Must have at least one entry in map."); New = Create_Blend_Map (Blend_Type); New->Set(tempList); - pigmentBlendMap = dynamic_pointer_cast(New); + pigmentBlendMap = std::dynamic_pointer_cast(New); if (pigmentBlendMap) { pigmentBlendMap->blendMode = blendMode; @@ -2915,23 +2559,7 @@ template SlopeBlendMapPtr Parser::Parse_Blend_Map (BlendMa template NormalBlendMapPtr Parser::Parse_Blend_Map (BlendMapTypeId Blend_Type,int Pat_Type); template TextureBlendMapPtr Parser::Parse_Blend_Map (BlendMapTypeId Blend_Type,int Pat_Type); -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** template<> void Parser::Parse_BlendListData (BlendMapTypeId Blend_Type, ColourBlendMapData& rData) @@ -3346,7 +2974,7 @@ ColourBlendMapPtr Parser::Parse_Colour_Map () EXPRESS Express; int Terms; ColourBlendMapEntry Temp_Ent, Temp_Ent_2; - vector tempList; + std::vector tempList; bool old_allow_id = Allow_Identifier_In_Call; Allow_Identifier_In_Call = false; int blendMode = 0; @@ -3653,25 +3281,7 @@ GenericSpline *Parser::Parse_Spline() return New; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::POV_strupr(char *s) { @@ -3679,29 +3289,11 @@ void Parser::POV_strupr(char *s) for (i = 0,len = (int)strlen(s); i < len; i++) { - s[i] = (char)toupper((int)s[i]); + s[i] = (char)std::toupper((int)s[i]); } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::POV_strlwr(char *s) { @@ -3709,7 +3301,7 @@ void Parser::POV_strlwr(char *s) for (i = 0,len = (int)strlen(s); i < len; i++) { - s[i] = (char)tolower((int)s[i]); + s[i] = (char)std::tolower((int)s[i]); } } @@ -3863,3 +3455,4 @@ void Parser::Destroy_Random_Generators() } } +// end of namespace pov_parser diff --git a/source/parser/parser_functions.cpp b/source/parser/parser_functions.cpp index 122b83907..a66b614fa 100644 --- a/source/parser/parser_functions.cpp +++ b/source/parser/parser_functions.cpp @@ -39,12 +39,25 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/parser.h" +// C++ variants of C standard header files +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/mathutil.h" +#include "base/pov_mem.h" +// POV-Ray header files (core module) #include "core/scene/scenedata.h" +// POV-Ray header files (VM module) #include "vm/fnpovfpu.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -57,7 +70,7 @@ using namespace pov; * Local typedefs ******************************************************************************/ -struct ExprParserTableEntry +struct ExprParserTableEntry final { int stage; TokenId token; @@ -66,7 +79,7 @@ struct ExprParserTableEntry int op; }; -struct ExprParserErrorEntry +struct ExprParserErrorEntry final { int stage; const char *expected; @@ -1187,13 +1200,13 @@ void Parser::optimise_call(ExprNode *node) result = tanh(node->child->number); break; case ASINH_TOKEN: - result = asinh(node->child->number); + result = std::asinh(node->child->number); break; case ACOSH_TOKEN: - result = acosh(node->child->number); + result = std::acosh(node->child->number); break; case ATANH_TOKEN: - result = atanh(node->child->number); + result = std::atanh(node->child->number); break; case ABS_TOKEN: result = fabs(node->child->number); @@ -1491,3 +1504,4 @@ void Parser::dump_expr(FILE *f, ExprNode *node) } } +// end of namespace pov_parser diff --git a/source/parser/parser_functions_utilities.cpp b/source/parser/parser_functions_utilities.cpp index 89d6e6d04..a6c3e0fca 100644 --- a/source/parser/parser_functions_utilities.cpp +++ b/source/parser/parser_functions_utilities.cpp @@ -39,13 +39,25 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/parser.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/pigment.h" #include "core/math/matrix.h" #include "core/math/spline.h" #include "core/scene/scenedata.h" +// POV-Ray header files (VM module) #include "vm/fnpovfpu.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -346,9 +358,10 @@ FUNCTION_PTR Parser::Parse_DeclareFunction(TokenId *token_id, const char *fn_nam return ptr; } -intrusive_ptr Parser::GetFunctionVM() const +boost::intrusive_ptr Parser::GetFunctionVM() const { return mpFunctionVM; } } +// end of namespace pov_parser diff --git a/source/parser/parser_fwd.h b/source/parser/parser_fwd.h new file mode 100644 index 000000000..48042d7d4 --- /dev/null +++ b/source/parser/parser_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file parser/parser_fwd.h +/// +/// Forward declarations of core module referenced by other modules. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_PARSER_FWD_H +#define POVRAY_PARSER_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_parser +{ + +class Parser; + +} +// end of namespace pov + +#endif // POVRAY_PARSER_FWD_H diff --git a/source/parser/parser_materials.cpp b/source/parser/parser_materials.cpp index 9852661f6..8fc1ddd16 100644 --- a/source/parser/parser_materials.cpp +++ b/source/parser/parser_materials.cpp @@ -36,10 +36,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/parser.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/fileutil.h" +#include "base/image/colourspace.h" #include "base/image/image.h" #include "base/path.h" +#include "base/stringutilities.h" +// POV-Ray header files (core module) #include "core/lighting/lightgroup.h" #include "core/material/blendmap.h" #include "core/material/interior.h" @@ -58,9 +67,14 @@ #include "core/shape/isosurface.h" #include "core/support/imageutil.h" +// POV-Ray header files (VM module) #include "vm/fnpovfpu.h" -#include "povms/povmsid.h" +// POV-Ray header files (parser module) +// (none at the moment) + +// POV-Ray header files (POVMS module) +#include "povms/povmsid.h" // TODO - only here for kPOVList_FileType_XXX #ifdef SYS_IMAGE_HEADER #include SYS_IMAGE_HEADER @@ -74,6 +88,9 @@ namespace pov_parser using namespace pov; +using std::shared_ptr; +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -115,7 +132,7 @@ void Parser::Make_Pattern_Image(ImageData *image, FUNCTION_PTR fn, int token) image->iheight = image->height; if(token == FUNCT_ID_TOKEN) { - image->data =Image::Create(image->iwidth, image->iheight, Image::Gray_Int16); + image->data =Image::Create(image->iwidth, image->iheight, ImageDataType::Gray_Int16); point[Z] = 0; @@ -137,7 +154,7 @@ void Parser::Make_Pattern_Image(ImageData *image, FUNCTION_PTR fn, int token) } else if((token == VECTFUNCT_ID_TOKEN) && (f->return_size == 5)) { - image->data =Image::Create(image->iwidth, image->iheight, Image::RGBA_Int16); // TODO - we should probably use a HDR format + image->data = Image::Create(image->iwidth, image->iheight, ImageDataType::RGBA_Int16); // TODO - we should probably use an HDR format image->data->SetPremultiplied(false); // We're storing the data in non-premultiplied alpha format, as this preserves all the data we're getting from the function. point[Z] = 0; @@ -364,7 +381,7 @@ ImageData *Parser::Parse_Image(int Legal, bool GammaCorrect) Error("File type not supported here."); UCS2String filename = SysToUCS2String(Name); - Image::ReadOptions options; + ImageReadOptions options; switch (sceneData->gammaMode) { @@ -483,7 +500,7 @@ ImageData *Parser::Parse_Image(int Legal, bool GammaCorrect) image->data = Read_Image(filetype, filename.c_str(), options); if (!options.warnings.empty()) - for (vector::iterator it = options.warnings.begin(); it != options.warnings.end(); it++) + for (vector::iterator it = options.warnings.begin(); it != options.warnings.end(); it++) Warning("%s: %s", Name, it->c_str()); POV_FREE(Name); @@ -1242,9 +1259,9 @@ void Parser::VerifyTilingPattern(shared_ptr pattern) void Parser::VerifyPattern(PatternPtr basicPattern) { - if (shared_ptr pattern = dynamic_pointer_cast(basicPattern)) + if (shared_ptr pattern = std::dynamic_pointer_cast(basicPattern)) VerifyPavementPattern(pattern); - else if (shared_ptr pattern = dynamic_pointer_cast(basicPattern)) + else if (shared_ptr pattern = std::dynamic_pointer_cast(basicPattern)) VerifyTilingPattern(pattern); } @@ -5406,3 +5423,4 @@ void Parser::Parse_PatternFunction(TPATTERN *New) } } +// end of namespace pov_parser diff --git a/source/parser/parser_obj.cpp b/source/parser/parser_obj.cpp index c67c5d5da..e43d68960 100644 --- a/source/parser/parser_obj.cpp +++ b/source/parser/parser_obj.cpp @@ -38,11 +38,22 @@ #if POV_PARSER_EXPERIMENTAL_OBJ_IMPORT +// C++ variants of C standard header files #include +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/interior.h" #include "core/shape/mesh.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -51,25 +62,28 @@ namespace pov_parser using namespace pov; +using std::max; +using std::vector; + static const int kMaxObjBufferSize = 1024; #define PAIR(c1,c2) ( ((int)(c1)) + (((int)(c2))<<8) ) #define TRIPLET(c1,c2,c3) ( ((int)(c1)) + (((int)(c2))<<8) + (((int)(c3))<<16) ) -struct FaceVertex +struct FaceVertex final { MeshIndex vertexId; MeshIndex normalId; MeshIndex uvId; }; -struct FaceData +struct FaceData final { FaceVertex vertexList[3]; MeshIndex materialId; }; -struct MaterialData +struct MaterialData final { std::string mtlName; TEXTURE *texture; @@ -574,5 +588,6 @@ void Parser::Parse_Obj (Mesh* mesh) } } +// end of namespace pov_parser #endif // POV_PARSER_EXPERIMENTAL_OBJ_IMPORT diff --git a/source/parser/parser_strings.cpp b/source/parser/parser_strings.cpp index a7de2f5f9..89c128421 100644 --- a/source/parser/parser_strings.cpp +++ b/source/parser/parser_strings.cpp @@ -41,15 +41,22 @@ #include #include +// C++ standard header files +// (none at the moment) + // Boost header files #include // POV-Ray header files (base module) +#include "base/pov_mem.h" #include "base/stringutilities.h" // POV-Ray header files (core module) #include "core/scene/scenedata.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -58,23 +65,7 @@ namespace pov_parser using namespace pov; -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** char *Parser::Parse_C_String(bool pathname) { @@ -98,24 +89,7 @@ void Parser::ParseString(UTF8String& s, bool pathname) POV_FREE(str); } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_String(bool pathname, bool require) { @@ -238,9 +212,7 @@ UCS2 *Parser::Parse_String(bool pathname, bool require) return New; } - -//**************************************************************************** - +//****************************************************************************** std::string Parser::Parse_SysString(bool pathname, bool require) { @@ -250,24 +222,7 @@ std::string Parser::Parse_SysString(bool pathname, bool require) return ret; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Str(bool pathname) { @@ -318,24 +273,7 @@ UCS2 *Parser::Parse_Str(bool pathname) return String_To_UCS2(temp4); } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_VStr(bool pathname) { @@ -417,24 +355,7 @@ UCS2 *Parser::Parse_VStr(bool pathname) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Concat(bool pathname) { @@ -465,24 +386,7 @@ UCS2 *Parser::Parse_Concat(bool pathname) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Chr(bool /*pathname*/) { @@ -501,24 +405,7 @@ UCS2 *Parser::Parse_Chr(bool /*pathname*/) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** #define PARSE_NOW_VAL_LENGTH 200 @@ -596,24 +483,7 @@ UCS2 *Parser::Parse_Datetime(bool pathname) return String_To_UCS2(val); } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Substr(bool pathname) { @@ -643,24 +513,7 @@ UCS2 *Parser::Parse_Substr(bool pathname) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Strupr(bool pathname) { @@ -676,24 +529,7 @@ UCS2 *Parser::Parse_Strupr(bool pathname) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Strlwr(bool pathname) { @@ -709,24 +545,7 @@ UCS2 *Parser::Parse_Strlwr(bool pathname) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::String_To_UCS2(const char *str) { @@ -778,8 +597,7 @@ UCS2 *Parser::String_To_UCS2(const char *str) return char_string; } - -/*****************************************************************************/ +//****************************************************************************** UCS2 *Parser::String_Literal_To_UCS2(const std::string& str) { @@ -893,24 +711,7 @@ UCS2 *Parser::String_Literal_To_UCS2(const std::string& str) return char_string; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** char *Parser::UCS2_To_String(const UCS2 *str) { @@ -986,24 +787,7 @@ UCS2 *Parser::Convert_UTF8_To_UCS2(const unsigned char *text_array, int *char_ar return char_array; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::UCS2_strcat(UCS2 *s1, const UCS2 *s2) { @@ -1019,56 +803,7 @@ UCS2 *Parser::UCS2_strcat(UCS2 *s1, const UCS2 *s2) return s1; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ - -int Parser::UCS2_strcmp(const UCS2 *s1, const UCS2 *s2) -{ - UCS2 t1, t2; - - while((t1 = *s1++) == (t2 = *s2++)) - { - if(t1 == 0) - return 0; - } - - return (t1 - t2); -} - - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** void Parser::UCS2_strcpy(UCS2 *s1, const UCS2 *s2) { @@ -1078,24 +813,7 @@ void Parser::UCS2_strcpy(UCS2 *s1, const UCS2 *s2) *s1 = 0; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** void Parser::UCS2_strncpy(UCS2 *s1, const UCS2 *s2, int n) { @@ -1105,24 +823,7 @@ void Parser::UCS2_strncpy(UCS2 *s1, const UCS2 *s2, int n) *s1 = 0; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** void Parser::UCS2_strupr(UCS2 *str) { @@ -1143,24 +844,7 @@ void Parser::UCS2_strupr(UCS2 *str) Warning("Non-ASCII character in string, strupr may not work as expected."); } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** void Parser::UCS2_strlwr(UCS2 *str) { @@ -1191,3 +875,4 @@ UCS2 *Parser::UCS2_strdup(const UCS2 *s) } } +// end of namespace pov_parser diff --git a/source/parser/parser_tokenizer.cpp b/source/parser/parser_tokenizer.cpp index 49cb6a218..f57a605ef 100644 --- a/source/parser/parser_tokenizer.cpp +++ b/source/parser/parser_tokenizer.cpp @@ -42,18 +42,24 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/parser.h" -#include +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files #include -#include +// POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/stringutilities.h" +#include "base/textstream.h" +#include "base/types.h" #include "base/version_info.h" +// POV-Ray header files (core module) #include "core/material/noise.h" #include "core/scene/scenedata.h" +// POV-Ray header files (parser module) #include "parser/scanner.h" #include "parser/rawtokenizer.h" @@ -66,6 +72,8 @@ namespace pov_parser using namespace pov_base; using namespace pov; +using std::shared_ptr; + #if POV_DEBUG unsigned int gBreakpointCounter = 0; #endif @@ -76,23 +84,7 @@ unsigned int gBreakpointCounter = 0; #define CALL(x) { if (!(x)) return (false); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Initialize_Tokenizer() { @@ -128,10 +120,8 @@ void Parser::Initialize_Tokenizer() CheckFileSignature(); } - //****************************************************************************** - void Parser::CheckFileSignature() { RawToken signature; @@ -151,24 +141,7 @@ void Parser::CheckFileSignature() } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::pre_init_tokenizer () { @@ -192,24 +165,7 @@ void Parser::pre_init_tokenizer () MaxCachedMacroSize = POV_PARSER_MAX_CACHED_MACRO_SIZE; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Terminate_Tokenizer() { @@ -747,7 +703,6 @@ inline void Parser::Write_Token(TokenId Token_Id, const RawToken& rawToken, Symb mToken.table = table; } - //****************************************************************************** void Parser::Token_Struct::SetTokenId(const RawToken& rawToken) @@ -774,6 +729,11 @@ TokenId Parser::Token_Struct::GetCategorizedTokenId() const return mCategorizedTokenId; } +UCS2String Parser::Token_Struct::GetFileName() const +{ + return sourceFile->Name(); +} + //------------------------------------------------------------------------------ TokenId Parser::CurrentCategorizedTokenId() const @@ -912,23 +872,7 @@ bool Parser::GoToBookmark(const RawTokenizer::HotBookmark& bookmark) return true; } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** const char *Parser::Get_Token_String (TokenId Token_Id) { @@ -940,26 +884,7 @@ const char *Parser::Get_Token_String (TokenId Token_Id) return (""); } - - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** bool Parser::GetRawToken(RawToken& rawToken, bool fastForwardToDirective) { @@ -986,24 +911,7 @@ bool Parser::PeekRawToken(RawToken& rawToken) return true; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::UngetRawToken(const RawToken& rawToken) { @@ -1743,7 +1651,7 @@ void Parser::Parse_Directive() } } -/*****************************************************************************/ +//****************************************************************************** #if POV_DEBUG void Parser::Parse_Breakpoint() @@ -1763,7 +1671,7 @@ void Parser::Parse_Breakpoint() } #endif -/*****************************************************************************/ +//****************************************************************************** void Parser::Parse_Version() { @@ -1851,23 +1759,7 @@ void Parser::Parse_Version() parsingVersionDirective = wasParsingVersionDirective; } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Open_Include() { @@ -1881,25 +1773,7 @@ void Parser::Open_Include() IncludeHeader(formalFileName); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Skip_Tokens(COND_TYPE cond) { @@ -1926,24 +1800,7 @@ void Parser::Skip_Tokens(COND_TYPE cond) } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Break() { @@ -2764,8 +2621,8 @@ int Parser::Parse_Read_Value(DATA_FILE *User_File, TokenId Previous, TokenId *Nu case STRING_LITERAL_TOKEN: *NumberPtr = STRING_ID_TOKEN; Test_Redefine(Previous,NumberPtr,*DataPtr); - POV_PARSER_ASSERT(dynamic_pointer_cast(User_File->inToken.value) != nullptr); - *DataPtr = UCS2_strdup(dynamic_pointer_cast(User_File->inToken.value)->GetData().c_str()); + POV_PARSER_ASSERT(std::dynamic_pointer_cast(User_File->inToken.value) != nullptr); + *DataPtr = UCS2_strdup(std::dynamic_pointer_cast(User_File->inToken.value)->GetData().c_str()); break; default: @@ -3106,23 +2963,7 @@ int Parser::Parse_For_Param (UTF8String& identifierName, DBL* EndPtr, DBL* StepP ((*StepPtr < 0) && (*CurrentPtr > *EndPtr - EPSILON)); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::IncludeHeader(const UCS2String& formalFileName) { @@ -3147,3 +2988,4 @@ void Parser::IncludeHeader(const UCS2String& formalFileName) } } +// end of namespace pov_parser diff --git a/source/parser/parsertypes.cpp b/source/parser/parsertypes.cpp index 7e573ca4c..5bdc6aa18 100644 --- a/source/parser/parsertypes.cpp +++ b/source/parser/parsertypes.cpp @@ -43,7 +43,9 @@ // POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/povassert.h" +// POV-Ray header files (core module) // POV-Ray header files (parser module) // (none at the moment) @@ -129,3 +131,4 @@ InvalidEscapeSequenceException::InvalidEscapeSequenceException(const UCS2String& {} } +// end of namespace pov_parser diff --git a/source/parser/parsertypes.h b/source/parser/parsertypes.h index 0c0c719ae..4fcf84a17 100644 --- a/source/parser/parsertypes.h +++ b/source/parser/parsertypes.h @@ -40,21 +40,24 @@ #include "parser/configparser.h" // C++ variants of C standard header files +// (none at the moment) + // C++ standard header files +#include + // Boost header files // (none at the moment) // POV-Ray header files (base module) -#include "base/types.h" +#include "base/fileinputoutput_fwd.h" #include "base/messenger.h" +#include "base/stringtypes.h" // POV-Ray header files (core module) #include "core/coretypes.h" -namespace pov_base -{ -class IStream; -} +// POV-Ray header files (parser module) +// (none at the moment) namespace pov_parser { @@ -65,8 +68,8 @@ enum TokenId : int; //------------------------------------------------------------------------------ -using StreamPtr = shared_ptr; -using ConstStreamPtr = shared_ptr; +using StreamPtr = std::shared_ptr; +using ConstStreamPtr = std::shared_ptr; //------------------------------------------------------------------------------ @@ -113,7 +116,7 @@ struct TokenizerException : std::exception, MessageContext /// (`/*`) was encountered without a matching end sequence (`*/`), implying a /// broken comment or a comment nesting error. /// -struct IncompleteCommentException : TokenizerException +struct IncompleteCommentException final : TokenizerException { IncompleteCommentException(const UCS2String& osn, const LexemePosition& op); }; @@ -124,7 +127,7 @@ struct IncompleteCommentException : TokenizerException /// @ref RawTokenizer) to indicate that an unbalanced double quote (`"`) was /// encountered, implying a broken string literal. /// -struct IncompleteStringLiteralException : TokenizerException +struct IncompleteStringLiteralException final : TokenizerException { IncompleteStringLiteralException(const UCS2String& osn, const LexemePosition& op); }; @@ -136,7 +139,7 @@ struct IncompleteStringLiteralException : TokenizerException /// in the data stream does not conform to the expected character encoding /// scheme, implying a broken or malformed file. /// -struct InvalidEncodingException : TokenizerException +struct InvalidEncodingException final : TokenizerException { /// Descriptive name of the expected encoding scheme. const char* encodingName; @@ -155,7 +158,7 @@ struct InvalidEncodingException : TokenizerException /// @ref RawTokenizer) to indicate that an unexpected ASCII control character /// or non-ASCII character was encountered outside a string literal or comment. /// -struct InvalidCharacterException : TokenizerException +struct InvalidCharacterException final : TokenizerException { /// UCS code point corresponding to the unexpected character. UCS4 offendingCharacter; @@ -172,7 +175,7 @@ struct InvalidCharacterException : TokenizerException /// literal, malformed escape sequence or failure to properly escape a literal /// backslash character. /// -struct InvalidEscapeSequenceException : TokenizerException +struct InvalidEscapeSequenceException final : TokenizerException { /// Offending escape sequence, including leading escape character. UTF8String offendingText; @@ -187,13 +190,13 @@ struct InvalidEscapeSequenceException : TokenizerException /// Base class for miscellaneous things that can be assigned to a symbol. struct Assignable { - virtual ~Assignable() {} + virtual ~Assignable() = default; virtual Assignable* Clone() const = 0; }; //------------------------------------------------------------------------------ -struct ParserOptions +struct ParserOptions final { bool useClock; DBL clock; @@ -222,6 +225,25 @@ enum class CharacterEncodingID //------------------------------------------------------------------------------ -} // end of namespace +struct FileResolver +{ + virtual ~FileResolver() = default; + virtual pov_base::UCS2String FindFile(pov_base::UCS2String parsedFileName, unsigned int fileType) = 0; + virtual pov_base::IStream* ReadFile(const pov_base::UCS2String& parsedFileName, + const pov_base::UCS2String& foundFileName, unsigned int fileType) = 0; + virtual pov_base::OStream* CreateFile(const pov_base::UCS2String& parsedFileName, + unsigned int fileType, bool append) = 0; +}; + +struct ProgressReporter +{ + virtual ~ProgressReporter() = default; + virtual void ReportProgress(POV_LONG tokenCount) = 0; +}; + +//------------------------------------------------------------------------------ + +} +// end of namespace pov_parser #endif // POVRAY_PARSER_PARSERTYPES_H diff --git a/source/parser/precomp.h b/source/parser/precomp.h index a8a89c6b3..a8f5d0853 100644 --- a/source/parser/precomp.h +++ b/source/parser/precomp.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "parser/configparser.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,13 +70,12 @@ #include #include +// Boost header files #include #include #include #include #include -#include -#include #if POV_MULTITHREADED #include #include diff --git a/source/parser/rawtokenizer.cpp b/source/parser/rawtokenizer.cpp index 40591afbd..64040782f 100644 --- a/source/parser/rawtokenizer.cpp +++ b/source/parser/rawtokenizer.cpp @@ -39,7 +39,14 @@ // C++ variants of C standard header files // C++ standard header files // Boost header files +// (none at the moment) + // POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/povassert.h" +#include "base/stringutilities.h" + +// POV-Ray header files (core module) // (none at the moment) // POV-Ray header files (parser module) @@ -68,6 +75,13 @@ static bool IsUCS4ScalarValue(UCS4 c) //****************************************************************************** +void AmbiguousStringValue::InvalidEscapeSequenceInfo::Throw() const +{ + throw InvalidEscapeSequenceException(stream->Name(), position, text); +} + +//****************************************************************************** + TokenId RawToken::GetTokenId() const { if (id <= TOKEN_COUNT) @@ -200,8 +214,8 @@ bool RawTokenizer::ProcessStringLiteralLexeme(RawToken& token) token.id = int(STRING_LITERAL_TOKEN); token.expressionId = STRING_LITERAL_TOKEN; - shared_ptr pValue(std::make_shared()); - shared_ptr pAmbiguousValue; + std::shared_ptr pValue(std::make_shared()); + std::shared_ptr pAmbiguousValue; UCS4 c; pValue->data.reserve(token.lexeme.text.size() - 2); @@ -467,3 +481,4 @@ bool RawTokenizer::GoToBookmark(const ColdBookmark& bookmark) } } +// end of namespace pov_parser diff --git a/source/parser/rawtokenizer.h b/source/parser/rawtokenizer.h index e9e42fb88..80bece576 100644 --- a/source/parser/rawtokenizer.h +++ b/source/parser/rawtokenizer.h @@ -43,10 +43,16 @@ // (none at the moment) // C++ standard header files +#include #include // Boost header files +// (none at the moment) + // POV-Ray header files (base module) +#include "base/stringtypes.h" + +// POV-Ray header files (core module) // (none at the moment) // POV-Ray header files (parser module) @@ -68,8 +74,8 @@ struct Value Value() {} }; -using ValuePtr = shared_ptr; -using ConstValuePtr = shared_ptr; +using ValuePtr = std::shared_ptr; +using ConstValuePtr = std::shared_ptr; /// Structure representing a string value. struct StringValue : Value @@ -82,9 +88,9 @@ struct StringValue : Value }; /// Structure representing a string value with backslashes. -struct AmbiguousStringValue : StringValue +struct AmbiguousStringValue final : StringValue { - struct InvalidEscapeSequenceInfo + struct InvalidEscapeSequenceInfo final { ConstStreamPtr stream; LexemePosition position; @@ -92,7 +98,7 @@ struct AmbiguousStringValue : StringValue InvalidEscapeSequenceInfo(ConstStreamPtr s, LexemePosition p, UTF8String t) : stream(s), position(p), text(t) {} InvalidEscapeSequenceInfo(ConstStreamPtr s, LexemePosition p, const UTF8String::const_iterator& b, const UTF8String::const_iterator& e) : stream(s), position(p), text(b, e) {} - void Throw() const { throw InvalidEscapeSequenceException(stream->Name(), position, text); } + void Throw() const; }; UCS2String data; @@ -100,7 +106,7 @@ struct AmbiguousStringValue : StringValue InvalidEscapeSequenceInfo* invalidEscapeSequence; AmbiguousStringValue(const StringValue& o) : data(o.GetData()), fileName(o.GetFileName()), invalidEscapeSequence(nullptr) {} AmbiguousStringValue(const AmbiguousStringValue& o) : data(o.data), fileName(o.fileName), invalidEscapeSequence(o.invalidEscapeSequence) {} - ~AmbiguousStringValue() { if (invalidEscapeSequence != nullptr) delete invalidEscapeSequence; } + virtual ~AmbiguousStringValue() override { if (invalidEscapeSequence != nullptr) delete invalidEscapeSequence; } virtual const UCS2String& GetData() const override { if (invalidEscapeSequence != nullptr) invalidEscapeSequence->Throw(); return data; } virtual const UCS2String& GetFileName() const override { return fileName; } virtual bool IsAmbiguous() const override { return true; } @@ -110,7 +116,7 @@ struct AmbiguousStringValue : StringValue //------------------------------------------------------------------------------ /// Structure representing an individual raw token. -struct RawToken +struct RawToken final { /// The original lexeme from which this raw token was created. Lexeme lexeme; @@ -182,7 +188,7 @@ struct RawToken /// In addition, literal lexemes are evaluated, converting their textual /// representation into the corresponding internal value representation. /// -class RawTokenizer +class RawTokenizer final { public: @@ -235,7 +241,7 @@ class RawTokenizer private: - struct KnownWordInfo + struct KnownWordInfo final { int id; TokenId expressionId; @@ -258,5 +264,6 @@ class RawTokenizer }; } +// end of namespace pov_parser #endif // POVRAY_PARSER_RAWTOKENIZER_H diff --git a/source/parser/reservedwords.cpp b/source/parser/reservedwords.cpp index 356cd2c42..b716600bc 100644 --- a/source/parser/reservedwords.cpp +++ b/source/parser/reservedwords.cpp @@ -38,6 +38,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/parser.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -751,4 +760,5 @@ TokenId GetCategorizedTokenId(TokenId tokenId) return tokenId; } -} // end of namespace pov_parser +} +// end of namespace pov_parser diff --git a/source/parser/reservedwords.h b/source/parser/reservedwords.h index 9bb1dd081..91031d49a 100644 --- a/source/parser/reservedwords.h +++ b/source/parser/reservedwords.h @@ -40,18 +40,26 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "parser/configparser.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + +// POV-Ray header files (parser module) #include "parser/parsertypes.h" namespace pov_parser { -typedef struct Reserved_Word_Struct RESERVED_WORD; - -struct Reserved_Word_Struct +struct Reserved_Word_Struct final { TokenId Token_Number; const char *Token_Name; }; +using RESERVED_WORD = Reserved_Word_Struct; ///< @deprecated // Token Definitions for Parser enum TokenId : int @@ -757,6 +765,7 @@ extern const RESERVED_WORD Reserved_Words[]; TokenId GetCategorizedTokenId(TokenId tokenId); -} // end of namespace pov_parser +} +// end of namespace pov_parser #endif // POVRAY_PARSER_RESERVEDWORDS_H diff --git a/source/parser/scanner.cpp b/source/parser/scanner.cpp index 0ea6da8f3..885c55fb9 100644 --- a/source/parser/scanner.cpp +++ b/source/parser/scanner.cpp @@ -49,8 +49,12 @@ // (none at the moment) // POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/povassert.h" +#include "base/stringutilities.h" #include "base/textstream.h" +// POV-Ray header files (core module) // POV-Ray header files (parser module) // (none at the moment) @@ -561,6 +565,13 @@ static bool IsASCIIIdentifierChar2(Scanner::Character c) //****************************************************************************** +UCS2String Scanner::HotBookmark::GetFileName() const +{ + return pStream->Name(); +} + +//****************************************************************************** + Scanner::Buffer::Buffer() : mpEnd(maData), mpPos(maData) @@ -1469,4 +1480,5 @@ bool Scanner::IsNextCharacterIdentifierChar2() const //------------------------------------------------------------------------------ -} // end of namespace pov_parser +} +// end of namespace pov_parser diff --git a/source/parser/scanner.h b/source/parser/scanner.h index e14d1ccbc..68365cd32 100644 --- a/source/parser/scanner.h +++ b/source/parser/scanner.h @@ -44,15 +44,18 @@ // C++ standard header files #include -#include +#include // Boost header files // (none at the moment) // POV-Ray header files (base module) -#include "base/messenger.h" -#include "base/types.h" -#include "base/textstream.h" +#include "base/messenger_fwd.h" +#include "base/stringtypes.h" +#include "base/textstream_fwd.h" + +// POV-Ray header files (core module) +// (none at the moment) // POV-Ray header files (parser module) #include "parser/parsertypes.h" @@ -68,7 +71,7 @@ struct CharacterEncoding; //****************************************************************************** -struct Lexeme +struct Lexeme final { enum Category : unsigned char { @@ -116,7 +119,7 @@ struct Lexeme /// - Single octets in the range 0x00 0x7F must always encode the /// corresponding ASCII character. /// -class Scanner +class Scanner final { public: @@ -143,18 +146,18 @@ class Scanner }; /// Structure representing an open input stream and a rewindable position. - struct HotBookmark : Bookmark + struct HotBookmark final : Bookmark { StreamPtr pStream; HotBookmark() = default; HotBookmark(const StreamPtr& s, const LexemePosition& lp, CharacterEncodingPtr se, Character neol, bool anbc) : Bookmark(lp, se, neol, anbc), pStream(s) {} - virtual UCS2String GetFileName() const override { return pStream->Name(); } + virtual UCS2String GetFileName() const override; }; /// Structure representing an input stream name and a rewindable position. - struct ColdBookmark : Bookmark + struct ColdBookmark final : Bookmark { UCS2String fileName; ColdBookmark() = default; @@ -787,5 +790,6 @@ class Scanner }; } +// end of namespace pov_parser #endif // POVRAY_PARSER_SCANNER_H diff --git a/source/parser/symboltable.cpp b/source/parser/symboltable.cpp index dbeab7976..071c7acf3 100644 --- a/source/parser/symboltable.cpp +++ b/source/parser/symboltable.cpp @@ -42,6 +42,8 @@ // (none at the moment) // POV-Ray header files (base module) +#include "base/pov_mem.h" +#include "base/povassert.h" #include "base/stringutilities.h" // POV-Ray header files (core module) @@ -661,4 +663,5 @@ SymbolTable& SymbolStack::GetGlobalTable() //****************************************************************************** -} // end of namespace +} +// end of namespace pov_parser diff --git a/source/parser/symboltable.h b/source/parser/symboltable.h index bd9c08c11..de34cbb23 100644 --- a/source/parser/symboltable.h +++ b/source/parser/symboltable.h @@ -49,7 +49,10 @@ // (none at the moment) // POV-Ray header files (base module) -#include "base/types.h" +#include "base/stringtypes.h" + +// POV-Ray header files (core module) +// (none at the moment) // POV-Ray header files (parser module) #include "parser/parsertypes.h" @@ -65,7 +68,6 @@ using namespace pov_base; const int MAX_NUMBER_OF_TABLES = 100; const int SYM_TABLE_SIZE = 257; -typedef struct Sym_Table_Entry SYM_ENTRY; typedef unsigned short SymTableEntryRefCount; // Special symbol tables @@ -75,9 +77,9 @@ enum }; /// Structure holding information about a symbol -struct Sym_Table_Entry +struct Sym_Table_Entry final { - SYM_ENTRY *next; ///< Reference to next symbol with same hash + Sym_Table_Entry *next; ///< Reference to next symbol with same hash UTF8String name; ///< Symbol name char *Deprecation_Message; ///< Warning to print if the symbol is deprecated void *Data; ///< Reference to the symbol value @@ -87,10 +89,11 @@ struct Sym_Table_Entry bool deprecatedShown : 1; SymTableEntryRefCount ref_count; ///< normally 1, but may be greater when passing symbols out of macros }; +using SYM_ENTRY = Sym_Table_Entry; ///< @deprecated //------------------------------------------------------------------------------ -struct SymbolTable +struct SymbolTable final { SymbolTable(); SymbolTable(const SymbolTable& obj); @@ -137,7 +140,7 @@ using SymbolTablePtr = std::shared_ptr; //------------------------------------------------------------------------------ -class SymbolStack +class SymbolStack final { public: @@ -180,6 +183,7 @@ class SymbolStack int Table_Index; }; -} // end of namespace +} +// end of namespace pov_parser #endif // POVRAY_PARSER_SYMBOLTABLE_H diff --git a/source/povmain.cpp b/source/povmain.cpp index acf16adfd..3f296b697 100644 --- a/source/povmain.cpp +++ b/source/povmain.cpp @@ -38,13 +38,18 @@ #include +#include + // configfrontend.h must always be the first POV file included in frontend sources (pulls in platform config) #include "frontend/configfrontend.h" +// POV-Ray header files (base module) #include "base/timer.h" +// POV-Ray header files (backend module) #include "backend/povray.h" +// POV-Ray header files (frontend module) #include "frontend/console.h" #include "frontend/display.h" #include "frontend/filemessagehandler.h" @@ -63,18 +68,18 @@ class DefaultConsole : public pov_frontend::Console { public: DefaultConsole() { } - ~DefaultConsole() { } - void Initialise() { } - void Output(const string& str) { std::printf("%s\n", str.c_str()); std::fflush(stdout); } + virtual ~DefaultConsole() override { } + virtual void Initialise() override { } + virtual void Output (const string& str) override { std::printf("%s\n", str.c_str()); std::fflush(stdout); } }; class DefaultDisplay : public pov_frontend::Display { public: DefaultDisplay(unsigned int w, unsigned int h) : Display(w, h) { } - ~DefaultDisplay() { } - void Initialise() { } - void DrawPixel(unsigned int, unsigned int, const RGBA8&) { } + virtual ~DefaultDisplay() override { } + virtual void Initialise() override { } + virtual void DrawPixel (unsigned int, unsigned int, const RGBA8&) override { } }; pov_frontend::Console *CreateDefaultConsole(); diff --git a/source/povms/configpovms.h b/source/povms/configpovms.h index 0237d8512..0a3eb94b4 100644 --- a/source/povms/configpovms.h +++ b/source/povms/configpovms.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -44,6 +44,7 @@ #error "povms.c must be compiled as a C++ file when used as part of the POV-Ray project." #endif +// Pull in other compile-time config header files first #include "base/configbase.h" #include "syspovconfigpovms.h" @@ -83,7 +84,7 @@ #endif #ifndef POVMSUCS2 - #define POVMSUCS2 UCS2 + #define POVMSUCS2 char16_t #endif #ifndef kDefaultTimeout diff --git a/source/povms/povmscpp.h b/source/povms/povmscpp.h index 685437282..25ef1ab53 100644 --- a/source/povms/povmscpp.h +++ b/source/povms/povmscpp.h @@ -37,10 +37,11 @@ #ifndef POVMSCPP_H #define POVMSCPP_H +#include "povms/povms.h" // pulls in config + #include #include -#include "povms/povms.h" #include "base/pov_err.h" /// @file @@ -78,7 +79,7 @@ class POVMS_Container void DetachData(); }; -class POVMS_Attribute : public POVMS_Container +class POVMS_Attribute final : public POVMS_Container { public: POVMS_Attribute(); @@ -95,7 +96,7 @@ class POVMS_Attribute : public POVMS_Container POVMS_Attribute(std::vector& value); POVMS_Attribute(POVMSAttribute& convert); POVMS_Attribute(const POVMS_Attribute& source); - virtual ~POVMS_Attribute() noexcept(false); + virtual ~POVMS_Attribute() noexcept(false) override; POVMS_Attribute& operator=(const POVMS_Attribute& source); @@ -122,13 +123,13 @@ class POVMS_Attribute : public POVMS_Container int GetVectorSize() const; }; -class POVMS_List : public POVMS_Container +class POVMS_List final : public POVMS_Container { public: POVMS_List(); POVMS_List(POVMSAttributeList& convert); POVMS_List(const POVMS_List& source); - virtual ~POVMS_List() noexcept(false); + virtual ~POVMS_List() noexcept(false) override; POVMS_List& operator=(const POVMS_List& source); @@ -171,22 +172,22 @@ class POVMS_Object : public POVMS_Container virtual bool write(void *, int) = 0; }; - template class InputStreamT : public InputStream + template class InputStreamT final : public InputStream { public: InputStreamT(T& s) : stream(s) { } - virtual ~InputStreamT() { } - virtual bool read(void *ptr, int cnt) { return !(!stream.read(ptr, (size_t)cnt)); } + virtual ~InputStreamT() override { } + virtual bool read(void *ptr, int cnt) override { return !(!stream.read(ptr, (size_t)cnt)); } private: T& stream; }; - template class OutputStreamT : public OutputStream + template class OutputStreamT final : public OutputStream { public: OutputStreamT(T& s) : stream(s) { } - virtual ~OutputStreamT() { } - virtual bool write(void *ptr, int cnt) { return !(!stream.write(ptr, (size_t)cnt)); } + virtual ~OutputStreamT() override { } + virtual bool write(void *ptr, int cnt) override { return !(!stream.write(ptr, (size_t)cnt)); } private: T& stream; }; @@ -275,7 +276,7 @@ class POVMS_Object : public POVMS_Container void Write(OutputStream& stream, bool append, bool compress); }; -class POVMS_Message : public POVMS_Object +class POVMS_Message final : public POVMS_Object { public: POVMS_Message(); @@ -312,7 +313,7 @@ class POVMS_MessageReceiver virtual void Call(POVMSObjectPtr, POVMSObjectPtr, int) = 0; }; protected: - template class MemberHandlerOO : public HandlerOO + template class MemberHandlerOO final : public HandlerOO { public: typedef void (T::*MemberHandlerPtr)(POVMS_Message&, POVMS_Message&, int); @@ -329,7 +330,7 @@ class POVMS_MessageReceiver handlerptr = hptr; } - void Call(POVMS_Message& msg, POVMS_Message& result, int mode) + virtual void Call(POVMS_Message& msg, POVMS_Message& result, int mode) override { if ((classptr != nullptr) && (handlerptr != nullptr)) (classptr->*handlerptr)(msg, result, mode); @@ -341,7 +342,7 @@ class POVMS_MessageReceiver T *classptr; }; - template class MemberHandler : public Handler + template class MemberHandler final : public Handler { public: typedef void (T::*MemberHandlerPtr)(POVMSObjectPtr, POVMSObjectPtr, int); @@ -358,7 +359,7 @@ class POVMS_MessageReceiver handlerptr = hptr; } - void Call(POVMSObjectPtr msg, POVMSObjectPtr result, int mode) + virtual void Call(POVMSObjectPtr msg, POVMSObjectPtr result, int mode) override { if ((classptr != nullptr) && (handlerptr != nullptr)) (classptr->*handlerptr)(msg, result, mode); @@ -370,7 +371,7 @@ class POVMS_MessageReceiver T *classptr; }; - class FunctionHandlerOO : public HandlerOO + class FunctionHandlerOO final : public HandlerOO { public: typedef void (*FunctionHandlerPtr)(POVMS_Message&, POVMS_Message&, int, void *); @@ -387,7 +388,7 @@ class POVMS_MessageReceiver privatedata = pptr; } - void Call(POVMS_Message& msg, POVMS_Message& result, int mode) + virtual void Call(POVMS_Message& msg, POVMS_Message& result, int mode) override { if (handlerptr != nullptr) handlerptr(msg, result, mode, privatedata); @@ -399,7 +400,7 @@ class POVMS_MessageReceiver void *privatedata; }; - class FunctionHandler : public Handler + class FunctionHandler final : public Handler { public: typedef void (*FunctionHandlerPtr)(POVMSObjectPtr, POVMSObjectPtr, int, void *); @@ -416,7 +417,7 @@ class POVMS_MessageReceiver privatedata = pptr; } - void Call(POVMSObjectPtr msg, POVMSObjectPtr result, int mode) + virtual void Call(POVMSObjectPtr msg, POVMSObjectPtr result, int mode) override { if (handlerptr != nullptr) handlerptr(msg, result, mode, privatedata); @@ -473,7 +474,7 @@ class POVMS_MessageReceiver void Remove(POVMSType hclass, POVMSType hid); private: - struct HandlerNode + struct HandlerNode final { struct HandlerNode *last; struct HandlerNode *next; @@ -486,9 +487,9 @@ class POVMS_MessageReceiver POVMSContext context; HandlerNode *receivers; - POVMS_MessageReceiver(); // default constructor not allowed - POVMS_MessageReceiver(const POVMS_MessageReceiver&); // no copies allowed - POVMS_MessageReceiver& operator=(const POVMS_MessageReceiver&); // no copy assignments allowed + POVMS_MessageReceiver() = delete; + POVMS_MessageReceiver(const POVMS_MessageReceiver&) = delete; + POVMS_MessageReceiver& operator=(const POVMS_MessageReceiver&) = delete; static POVMSResult ReceiveHandler(POVMSObjectPtr msg, POVMSObjectPtr result, int mode, void *privatedataptr); diff --git a/source/povms/povmsutil.cpp b/source/povms/povmsutil.cpp index 8f7b5b6c1..f813509fd 100644 --- a/source/povms/povmsutil.cpp +++ b/source/povms/povmsutil.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -74,3 +74,4 @@ int POVMSUtil_SetFormatString(POVMSObjectPtr object, POVMSType key, const char * } } +// end of namespace pov diff --git a/source/povms/povmsutil.h b/source/povms/povmsutil.h index 1eab5687f..215700ffd 100644 --- a/source/povms/povmsutil.h +++ b/source/povms/povmsutil.h @@ -9,7 +9,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -37,7 +37,7 @@ #ifndef POV_POVMSUTIL_H #define POV_POVMSUTIL_H -#include "povms/povms.h" +#include "povms/povms.h" // pulls in config namespace pov { @@ -48,5 +48,6 @@ int Send_Progress(const char *statusString, int progressState); int Send_ProgressUpdate(int progressState, int timeDiff = 1); } +// end of namespace pov #endif // POV_POVMSUTIL_H diff --git a/source/povms/precomp.h b/source/povms/precomp.h index 1dfec67ba..9ad2a0b3e 100644 --- a/source/povms/precomp.h +++ b/source/povms/precomp.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "base/configbase.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,16 +70,13 @@ #include #include +// Boost header files #include #include #include #include -#include -#include -#include #if POV_MULTITHREADED #include #include #endif #include - diff --git a/source/vm/configvm.h b/source/vm/configvm.h index d086f78e8..503bb3d41 100644 --- a/source/vm/configvm.h +++ b/source/vm/configvm.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,6 +38,7 @@ #ifndef POVRAY_VM_CONFIGVM_H #define POVRAY_VM_CONFIGVM_H +// Pull in other compile-time config header files first #include "core/configcore.h" #include "syspovconfigvm.h" diff --git a/source/vm/fnintern.cpp b/source/vm/fnintern.cpp index 839fb77e7..c09c84cc2 100644 --- a/source/vm/fnintern.cpp +++ b/source/vm/fnintern.cpp @@ -12,7 +12,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,10 +40,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "vm/fnintern.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/mathutil.h" +// POV-Ray header files (core module) #include "core/material/noise.h" #include "core/material/pigment.h" #include "core/material/warp.h" @@ -52,6 +58,7 @@ #include "core/scene/scenedata.h" #include "core/scene/tracethreaddata.h" +// POV-Ray header files (VM module) #include "vm/fnpovfpu.h" // this must be the last file included @@ -60,6 +67,9 @@ namespace pov { +using std::max; +using std::min; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -1291,3 +1301,4 @@ void f_spline(FPUContext *ctx, DBL *ptr, unsigned int fn, unsigned int sp) // 2 } } +// end of namespace pov diff --git a/source/vm/fnintern.h b/source/vm/fnintern.h index 3b935d47a..a112841bf 100644 --- a/source/vm/fnintern.h +++ b/source/vm/fnintern.h @@ -12,7 +12,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -37,28 +37,37 @@ /// //****************************************************************************** -#ifndef POVRAY_BACKEND_FNINTERN_H -#define POVRAY_BACKEND_FNINTERN_H +#ifndef POVRAY_VM_FNINTERN_H +#define POVRAY_VM_FNINTERN_H // Module config header file must be the first file included within POV-Ray unit header files #include "vm/configvm.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + +// POV-Ray header files (VM module) +#include "vm/fnpovfpu_fwd.h" + namespace pov { -class FPUContext; - -typedef struct +struct Trap final { DBL (*fn)(FPUContext *ctx, DBL *ptr, unsigned int fn); unsigned int parameter_cnt; -} Trap; +}; -typedef struct +struct TrapS final { void (*fn)(FPUContext *ctx, DBL *ptr, unsigned int fn, unsigned int sp); unsigned int parameter_cnt; -} TrapS; +}; extern const Trap POVFPU_TrapTable[]; extern const TrapS POVFPU_TrapSTable[]; @@ -67,5 +76,6 @@ extern const unsigned int POVFPU_TrapTableSize; extern const unsigned int POVFPU_TrapSTableSize; } +// end of namespace pov -#endif // POVRAY_BACKEND_FNINTERN_H +#endif // POVRAY_VM_FNINTERN_H diff --git a/source/vm/fnpovfpu.cpp b/source/vm/fnpovfpu.cpp index 1212cd93c..3cfd68789 100644 --- a/source/vm/fnpovfpu.cpp +++ b/source/vm/fnpovfpu.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -231,16 +231,23 @@ Density of instruction set: 916 / 1024 = 0.8945 // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "vm/fnpovfpu.h" +// C++ variants of C standard header files +#include #include #include #include +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/mathutil.h" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/scene/tracethreaddata.h" +// POV-Ray header files (VM module) #include "vm/fnintern.h" // this must be the last file included @@ -249,6 +256,10 @@ Density of instruction set: 916 / 1024 = 0.8945 namespace pov { +using std::min; +using std::max; +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -477,9 +488,9 @@ const Sys1 POVFPU_Sys1Table[] = sinh, // 6 cosh, // 7 tanh, // 8 - asinh, // 9 - acosh, // 10 - atanh, // 11 + std::asinh, // 9 + std::acosh, // 10 + std::atanh, // 11 floor, // 12 ceil, // 13 sqrt, // 14 @@ -1650,3 +1661,4 @@ FPUContext::~FPUContext() } } +// end of namespace pov diff --git a/source/vm/fnpovfpu.h b/source/vm/fnpovfpu.h index 1d71679d3..2e459a2f0 100644 --- a/source/vm/fnpovfpu.h +++ b/source/vm/fnpovfpu.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -41,19 +41,30 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "vm/configvm.h" +#include "vm/fnpovfpu_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include -#include "base/textstream.h" +// Boost header files +#include + +// POV-Ray header files (base module) +#include "base/textstream_fwd.h" +// POV-Ray header files (core module) #include "core/coretypes.h" +// POV-Ray header files (VM module) +// (none at the moment) + namespace pov { -class FunctionVM; - #define MAX_CALL_STACK_SIZE 1024 #define INITIAL_DBL_STACK_SIZE 256 @@ -134,9 +145,6 @@ struct FunctionCode void *private_data; }; -typedef unsigned int FUNCTION; -typedef FUNCTION * FUNCTION_PTR; - struct FunctionEntry { FunctionCode fn; // valid if reference_count != 0 @@ -155,12 +163,12 @@ class FPUContext : public GenericFunctionContext { public: FPUContext(FunctionVM* pVm, TraceThreadData* pThreadData); - virtual ~FPUContext(); + virtual ~FPUContext() override; StackFrame *pstackbase; DBL *dblstackbase; unsigned int maxdblstacksize; - intrusive_ptr functionvm; + boost::intrusive_ptr functionvm; TraceThreadData *threaddata; #if (SYS_FUNCTIONS == 1) DBL *dblstack; @@ -257,22 +265,22 @@ class FunctionVM : public GenericFunctionContextFactory { public: CustomFunction(FunctionVM* pVm, FUNCTION_PTR pFn); - virtual ~CustomFunction(); - virtual GenericFunctionContextPtr AcquireContext(TraceThreadData* pThreadData); - virtual void ReleaseContext(GenericFunctionContextPtr pContext); - virtual void InitArguments(GenericFunctionContextPtr pContext); - virtual void PushArgument(GenericFunctionContextPtr pContext, DBL arg); - virtual DBL Execute(GenericFunctionContextPtr pContext); - virtual GenericScalarFunctionPtr Clone() const; - virtual const CustomFunctionSourceInfo* GetSourceInfo() const; + virtual ~CustomFunction() override; + virtual GenericFunctionContextPtr AcquireContext(TraceThreadData* pThreadData) override; + virtual void ReleaseContext(GenericFunctionContextPtr pContext) override; + virtual void InitArguments(GenericFunctionContextPtr pContext) override; + virtual void PushArgument(GenericFunctionContextPtr pContext, DBL arg) override; + virtual DBL Execute(GenericFunctionContextPtr pContext) override; + virtual GenericScalarFunctionPtr Clone() const override; + virtual const CustomFunctionSourceInfo* GetSourceInfo() const override; protected: - intrusive_ptr mpVm; + boost::intrusive_ptr mpVm; FUNCTION_PTR mpFn; static inline FPUContext* GetFPUContextPtr(GenericFunctionContextPtr pContext); }; FunctionVM(); - virtual ~FunctionVM(); + virtual ~FunctionVM() override; void Reset(); @@ -290,16 +298,17 @@ class FunctionVM : public GenericFunctionContextFactory FUNCTION_PTR CopyFunction(FUNCTION_PTR pK); void DestroyFunction(FUNCTION_PTR pK); - virtual GenericFunctionContextPtr CreateFunctionContext(TraceThreadData* pTd); + virtual GenericFunctionContextPtr CreateFunctionContext(TraceThreadData* pTd) override; private: - vector functions; + std::vector functions; FUNCTION nextUnreferenced; - vector globals; - vector consts; + std::vector globals; + std::vector consts; }; } +// end of namespace pov #endif // POVRAY_VM_FNPOVFPU_H diff --git a/source/vm/fnpovfpu_fwd.h b/source/vm/fnpovfpu_fwd.h new file mode 100644 index 000000000..06a58d4c9 --- /dev/null +++ b/source/vm/fnpovfpu_fwd.h @@ -0,0 +1,57 @@ +//****************************************************************************** +/// +/// @file vm/fnpovfpu_fwd.h +/// +/// Forward declarations related to the virtual machine executing render-time +/// functions. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +#ifndef POVRAY_VM_FNPOVFPU_FWD_H +#define POVRAY_VM_FNPOVFPU_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class FPUContext; +struct FunctionCode; +class FunctionVM; + +using FUNCTION = unsigned int; +using FUNCTION_PTR = FUNCTION*; + +} +// end of namespace pov + +#endif // POVRAY_VM_FNPOVFPU_FWD_H diff --git a/source/vm/precomp.h b/source/vm/precomp.h index bd882d311..46e5b0738 100644 --- a/source/vm/precomp.h +++ b/source/vm/precomp.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "base/configbase.h" // for POV_MULTITHREADED setting +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,13 +70,12 @@ #include #include +// Boost header files #include #include #include #include #include -#include -#include #if POV_MULTITHREADED #include #include diff --git a/unix/configure.ac b/unix/configure.ac index 7b284720b..bf4d62fe8 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -111,7 +111,7 @@ AX_ARG_WITH([--with-openexr], [DIR], [use the OpenEXR library (in director AC_ARG_VAR([COMPILED_BY], [customize the "unofficial version" message]) AC_ARG_VAR([NON_REDISTRIBUTABLE_BUILD], [see the installation documentation]) -AC_ARG_VAR([C99_COMPATIBLE_RADIOSITY], [adapt radiosity code to non-IEEE 754 floating point, requires ISO C99 compiler and library (see octree.cpp for details)]) +AC_ARG_VAR([C99_COMPATIBLE_RADIOSITY], [adapt radiosity code to non-IEEE 754 floating point (see configcore.h for details)]) ############################################################################### @@ -654,47 +654,25 @@ AC_CHECK_DECLS([RUSAGE_SELF, RUSAGE_THREAD, RUSAGE_LWP], # gettimeofday AC_CHECK_FUNCS([gettimeofday]) -# asinh and friends (requires libm) -AC_CHECK_FUNCS([asinh], - [], - [AC_DEFINE([NEED_INVHYP], [], [Inverse hyperbolic functions.])] -) +# (Not checking for `asinh` and friends anymore, as they are mandatory as of C++11. [CLi]) -# support for non-IEEE compilers (requires libm) +# support for non-IEEE compilers +# TODO FIXME - We should actually check for existence of `int32_t` rather than size of `int` now. if test x"$C99_COMPATIBLE_RADIOSITY" != x"" || test x"$ac_cv_sizeof_int" != x"4" || test x"$ac_cv_sizeof_float" != x"4"; then - AC_CHECK_FUNCS([copysign], - [], - [AC_MSG_ERROR([ -*** Cannot find the 'copysign' function required for non-ieee platform -])] - ) + # (Not checking for `copysign` anymore as we're no longer using it. [CLi]) if test x"$C99_COMPATIBLE_RADIOSITY" = x""; then # auto-detection - AC_CHECK_FUNCS([ilogbf], - [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [2], [See source/backend/support/octree.cpp for details.])], - [AC_CHECK_FUNCS([ilogb], - [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [4], [See source/backend/support/octree.cpp for details.])], - [AC_CHECK_FUNCS([logbf], - [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [1], [See source/backend/support/octree.cpp for details.])], - [AC_CHECK_FUNCS([logb], - [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [3], [See source/backend/support/octree.cpp for details.])], - [AC_MSG_ERROR([ -*** Cannot find a 'logb' or equivalent function required for non-ieee platform -])] - )] - )] - )] - ) - else # check value of C99_COMPATIBLE_RADIOSITY and function presence + # Simply choose `frexpf`/`ldexpf` variant; C++11 requires their existence, + # and they provide maximum portability at good performance. + AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [6], [See source/core/configcore.h for details.]) + else # check value of C99_COMPATIBLE_RADIOSITY + # (Not checking function presence anymore, as they are all mandatory as of C++11. [CLi]) case "$C99_COMPATIBLE_RADIOSITY" in - 1) AC_CHECK_FUNCS([logbf], [], [AC_MSG_ERROR([logbf not found])]) ;; - 2) AC_CHECK_FUNCS([ilogbf], [], [AC_MSG_ERROR([ilogbf not found])]) ;; - 3) AC_CHECK_FUNCS([logb], [], [AC_MSG_ERROR([logb not found])]) ;; - 4) AC_CHECK_FUNCS([ilogb], [], [AC_MSG_ERROR([ilogb not found])]) ;; + 1|2|3|4|5|6|7|8|9) ;; *) AC_MSG_ERROR([Unsupported C99_COMPATIBLE_RADIOSITY value]) ;; esac AC_DEFINE_UNQUOTED([C99_COMPATIBLE_RADIOSITY], [$C99_COMPATIBLE_RADIOSITY], - [See source/backend/support/octree.cpp for details.] + [See source/core/configcore.h for details.] ) fi fi @@ -736,6 +714,7 @@ if test x"$pov_compiler_vendor" = x"gnu"; then AX_TEST_COMPILER_FLAGS([-fno-enforce-eh-specs]) AX_TEST_COMPILER_FLAGS([-Wno-non-template-friend]) fi +AX_TEST_COMPILER_FLAGS([-Wsuggest-override]) # I/O restrictions. diff --git a/unix/disp.h b/unix/disp.h index b01178119..9cba70b1c 100644 --- a/unix/disp.h +++ b/unix/disp.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,24 +39,27 @@ #ifndef POVRAY_UNIX_DISP_H #define POVRAY_UNIX_DISP_H +#include + #include "vfe.h" namespace pov_frontend { using namespace vfe; - extern shared_ptr gDisplay; + extern std::shared_ptr gDisplay; class UnixDisplay : public vfeDisplay { public: UnixDisplay(unsigned int w, unsigned int h, vfeSession *session, bool visible) : vfeDisplay(w, h, session, visible) {}; - virtual ~UnixDisplay() {} ; - virtual void Initialise() = 0; - virtual void Close() = 0; - virtual void Show() = 0; - virtual void Hide() = 0; + virtual ~UnixDisplay() override {} ; + virtual void Initialise() override = 0; + virtual void Close() override = 0; + virtual void Show() override = 0; + virtual void Hide() override = 0; + virtual bool TakeOver(UnixDisplay *display) = 0; /** @@ -98,5 +101,6 @@ namespace pov_frontend return dynamic_cast(p) ; } } +// end of namespace pov_frontend #endif // POVRAY_UNIX_DISP_H diff --git a/unix/disp_sdl.cpp b/unix/disp_sdl.cpp index a1d8a0539..936ec5854 100644 --- a/unix/disp_sdl.cpp +++ b/unix/disp_sdl.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -115,7 +115,7 @@ namespace pov_frontend // allocate a new pixel counters, dropping influence of previous picture m_PxCount.clear(); // not useful, vector was created empty, just to be sure m_PxCount.reserve(width*height); // we need that, and the loop! - for(vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) + for(std::vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) (*iter) = 0; } @@ -219,7 +219,7 @@ namespace pov_frontend m_PxCount.clear(); m_PxCount.reserve(width*height); - for(vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) + for(std::vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) (*iter) = 0; m_update_rect.x = 0; @@ -516,7 +516,7 @@ namespace pov_frontend void UnixSDLDisplay::Clear() { - for(vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) + for(std::vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) (*iter) = 0; m_update_rect.x = 0; @@ -627,5 +627,6 @@ namespace pov_frontend } } +// end of namespace pov_frontend #endif /* HAVE_LIBSDL */ diff --git a/unix/disp_sdl.h b/unix/disp_sdl.h index dbbfe2742..63118ed54 100644 --- a/unix/disp_sdl.h +++ b/unix/disp_sdl.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -40,6 +40,8 @@ #ifdef HAVE_LIBSDL +#include + #include "vfe.h" #include "unixoptions.h" #include "disp.h" @@ -51,29 +53,29 @@ namespace pov_frontend using namespace vfe; using namespace vfePlatform; - class UnixSDLDisplay : public UnixDisplay + class UnixSDLDisplay final : public UnixDisplay { public: static const UnixOptionsProcessor::Option_Info Options[]; static bool Register(vfeUnixSession *session); UnixSDLDisplay(unsigned int w, unsigned int h, vfeSession *session, bool visible); - virtual ~UnixSDLDisplay(); - void Initialise(); - void Close(); - void Show(); - void Hide(); - bool TakeOver(UnixDisplay *display); - void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour); - void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour); - void Clear(); - bool HandleEvents(); - void UpdateScreen(bool Force); - void PauseWhenDoneNotifyStart(); - bool PauseWhenDoneResumeIsRequested(); - void PauseWhenDoneNotifyEnd(); + virtual ~UnixSDLDisplay() override; + virtual void Initialise() override; + virtual void Close() override; + virtual void Show() override; + virtual void Hide() override; + virtual bool TakeOver(UnixDisplay *display) override; + virtual void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour) override; + virtual void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + virtual void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + virtual void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour) override; + virtual void Clear() override; + virtual bool HandleEvents() override; + virtual void UpdateScreen(bool Force) override; + virtual void PauseWhenDoneNotifyStart() override; + virtual bool PauseWhenDoneResumeIsRequested() override; + virtual void PauseWhenDoneNotifyEnd() override; protected: /// Number of Pixels before the display is updated @@ -109,9 +111,10 @@ namespace pov_frontend SDL_Rect m_screen_rect; SDL_Rect m_update_rect; /// for mixing colors in scaled down display - vector m_PxCount; + std::vector m_PxCount; }; } +// end of namespace pov_frontend #endif /* HAVE_LIBSDL */ diff --git a/unix/disp_text.cpp b/unix/disp_text.cpp index 742fa1c34..0833487f3 100644 --- a/unix/disp_text.cpp +++ b/unix/disp_text.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -65,3 +65,4 @@ namespace pov_frontend //fprintf(stderr, "DrawPixel(%d,%d)\n", x, y); } } +// end of namespace pov_frontend diff --git a/unix/disp_text.h b/unix/disp_text.h index bce8af57e..64ce18515 100644 --- a/unix/disp_text.h +++ b/unix/disp_text.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -47,7 +47,7 @@ namespace pov_frontend using namespace vfe; using namespace vfePlatform; - class UnixTextDisplay : public UnixDisplay + class UnixTextDisplay final : public UnixDisplay { public: static const UnixOptionsProcessor::Option_Info Options[]; @@ -55,19 +55,20 @@ namespace pov_frontend UnixTextDisplay(unsigned int w, unsigned int h, vfeSession *session, bool visible) : UnixDisplay(w, h, session, visible) {}; - virtual ~UnixTextDisplay() {} ; - void Initialise() {}; - void Close() {}; - void Show() {}; - void Hide() {}; - bool TakeOver(UnixDisplay *display) { return false; }; - void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour); - bool HandleEvents() { return false; }; - void UpdateScreen(bool Force = false) {}; - void PauseWhenDoneNotifyStart() {}; - bool PauseWhenDoneResumeIsRequested() { return true; }; - void PauseWhenDoneNotifyEnd() {}; + virtual ~UnixTextDisplay() override {} ; + virtual void Initialise() override {}; + virtual void Close() override {}; + virtual void Show() override {}; + virtual void Hide() override {}; + virtual bool TakeOver(UnixDisplay *display) override { return false; }; + virtual void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour) override; + virtual bool HandleEvents() override { return false; }; + virtual void UpdateScreen(bool Force = false) override {}; + virtual void PauseWhenDoneNotifyStart() override {}; + virtual bool PauseWhenDoneResumeIsRequested() override { return true; }; + virtual void PauseWhenDoneNotifyEnd() override {}; }; } +// end of namespace pov_frontend #endif // POVRAY_UNIX_DISP_TEXT_H diff --git a/unix/install.txt b/unix/install.txt index c023eb753..4450db2eb 100644 --- a/unix/install.txt +++ b/unix/install.txt @@ -485,17 +485,15 @@ NON_REDISTRIBUTABLE_BUILD=yes options. Using this option means you acknowledge that the generated POV-Ray executable must *not* be redistributed. -C99_COMPATIBLE_RADIOSITY={1,2,3,4} +C99_COMPATIBLE_RADIOSITY={1,2,3,4,5,6,7,8,9} adapts the POV-Ray radiosity code to use non-IEEE 754 floating point on machines that do not support this standard. You must specify one of the possible values given above (e.g. C99_COMPATIBLE_RADIOSITY=2). - Each value corresponds to the C function 'logbf', 'ilogbf', 'logb', - and 'ilogb', respectively, to be used with the C function 'copysign'. - This option requires having an ISO C99 compiler and its accompanying - C library installed on your machine. More details are given near the - top of the octree.cpp source file. On platforms where integer ('int') - and single-precision floating-point ('float') numbers are not 32-bit, - configure will try to determine automatically which function to use. + Each value corresponds to a different implementation of certain basic + operations. More details are given in the configcore.h + source file. On platforms where integer ('int') and single-precision + floating-point ('float') numbers are not 32-bit, configure will try to + determine automatically which function to use. ================= diff --git a/unix/povconfig/syspovconfig.h b/unix/povconfig/syspovconfig.h index 079453b21..550bda809 100644 --- a/unix/povconfig/syspovconfig.h +++ b/unix/povconfig/syspovconfig.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,25 +39,6 @@ #ifndef POVRAY_UNIX_SYSPOVCONFIG_H #define POVRAY_UNIX_SYSPOVCONFIG_H -#define _FILE_OFFSET_BITS 64 // Required for some Unix flavors to get a 64-bit off_t type on 32-bit systems. - -// C++ variants of C standard headers -#include -#include - -// C++ standard headers -#include -#include -#include -#include -#include -#include -#include -#include - -// boost headers -#include - #ifdef HAVE_CONFIG_H // from directory "." (generated by ./configure) # include "config.h" @@ -65,49 +46,15 @@ # error "!!!!! config.h is required !!!!!" #endif -#ifdef HAVE_STDINT_H -#include "stdint.h" -#endif - -using std::max; -using std::min; - -#ifndef STD_TYPES_DECLARED -#define STD_TYPES_DECLARED - -// the following types are used extensively throughout the POV source and hence are -// included and named here for reasons of clarity and convenience. - -// when we say 'string' we mean std::string -using std::string; - -// and vector is a std::vector -using std::vector; - -// yup, list too -using std::list; - -// runtime_error is the base of our Exception class, plus is referred -// to in a few other places. -using std::runtime_error; - -// we use the C++11 standard shared pointers -using std::shared_ptr; -using std::weak_ptr; -using std::dynamic_pointer_cast; -using std::static_pointer_cast; -using std::const_pointer_cast; - -using boost::intrusive_ptr; - -#endif // STD_POV_TYPES_DECLARED +#define _FILE_OFFSET_BITS 64 // Required for some Unix flavors to get a 64-bit off_t type on 32-bit systems. -// After Stroustrup in _The C++ Programming Language, 3rd Ed_ p. 88 -#ifndef NULL -const int NULL=0; -#endif +// C++ variants of C standard headers +#include // TODO - Required for `PATH_MAX`, `_POSIX_PATH_MAX`, and `POV_ISINF()` emulated implementation. +#include // TODO - Required for `POV_ISNAN()` and `POV_ISINF()` default implementations. +#include // TODO - Required for `POV_INTn` and `POV_UINTn` default types. -#define POV_DELETE_FILE(name) unlink(name) +// C++ standard headers +#include // required for `POV_ISNAN` and `POV_ISINF` default implementations #if defined (PATH_MAX) // Use the system's actual limit if known. diff --git a/unix/povconfig/syspovconfig_bsd.h b/unix/povconfig/syspovconfig_bsd.h index df7379e22..d76ba3597 100644 --- a/unix/povconfig/syspovconfig_bsd.h +++ b/unix/povconfig/syspovconfig_bsd.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,29 +39,13 @@ #ifndef POVRAY_UNIX_SYSPOVCONFIG_BSD_H #define POVRAY_UNIX_SYSPOVCONFIG_BSD_H -#include +#include // Pulled in for `off_t`. +#include // Pulled in for `_POSIX_V6_xxx`. -#if defined(_POSIX_V6_LPBIG_OFFBIG) || defined(_POSIX_V6_LP64_OFF64) || defined(_POSIX_V6_ILP32_OFFBIG) - // `off_t` is at least 64 bits. - // This variant of BSD provides large file support via the `lseek` function, - // with file offsets having type `off_t`. - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#elif defined(_POSIX_V6_ILP32_OFF32) - // `off_t` is at least 32 bits. - // This variant of BSD does _not_ provide large file support via the `lseek` function. - // Comment-out the following line to proceed anyway. - #error "Image size will be limited to approx. 100 Megapixels. Proceed at your own risk." - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#else - // Unable to detect `off_t` size at compile-time. - // This variant of BSD _may or may not_ provide large file support via the `lseek` function. - // Comment-out the following line to proceed anyway - #error "Image size may be limited to approx. 100 Megapixels. Proceed at your own risk." - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#endif +// BSD does not seem to provide an explicit 64-bit `lseek`, so we're stuck with +// whatever size `off_t` happens to have. +#define POVUNIX_LSEEK64(h,o,w) lseek(h,o,w) +#define POV_OFF_T off_t /// @file /// @todo The POV_LONG stuff is just copied from the Posix settings; someone needs to verify universal BSD compatibility. diff --git a/unix/povconfig/syspovconfig_gnu.h b/unix/povconfig/syspovconfig_gnu.h index bd7629510..d118c1cfd 100644 --- a/unix/povconfig/syspovconfig_gnu.h +++ b/unix/povconfig/syspovconfig_gnu.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,11 +39,12 @@ #ifndef POVRAY_UNIX_SYSPOVCONFIG_GNU_H #define POVRAY_UNIX_SYSPOVCONFIG_GNU_H -#include +#include // Pulled in for `off64_t`. +#include // Pulled in for `_POSIX_V6_xxx`. -// GNU/Linux provides large file support via the `lseek64` function, -// with file offsets having type `off64_t`. -#define POV_LSEEK(handle,offset,whence) lseek64(handle,offset,whence) +// GNU/Linux provides large file support on all machines, via the `lseek64` +// function and `off64_t` type. (Requires `#define _FILE_OFFSET_BITS 64`.) +#define POVUNIX_LSEEK64(h,o,w) lseek64(h,o,w) #define POV_OFF_T off64_t #if defined(_POSIX_V6_LPBIG_OFFBIG) || defined(_POSIX_V6_LP64_OFF64) diff --git a/unix/povconfig/syspovconfig_osx.h b/unix/povconfig/syspovconfig_osx.h index 06500dfcc..62ac1c707 100644 --- a/unix/povconfig/syspovconfig_osx.h +++ b/unix/povconfig/syspovconfig_osx.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,13 +39,14 @@ #ifndef POVRAY_UNIX_SYSPOVCONFIG_OSX_H #define POVRAY_UNIX_SYSPOVCONFIG_OSX_H -#include +#include // Pulled in for `off_t`. +#include // Pulled in for `_POSIX_V6_xxx`. /// @file /// @todo Someone needs to verify that off_t is indeed always 64 bit on Mac OS X // OS X appears to provide large file support via the `lseek` function, // with file offsets having type `off_t`. -#define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) +#define POVUNIX_LSEEK64(h,o,w) lseek(h,o,w) #define POV_OFF_T off_t /// @file diff --git a/unix/povconfig/syspovconfig_posix.h b/unix/povconfig/syspovconfig_posix.h index db0b39380..be5a98a3b 100644 --- a/unix/povconfig/syspovconfig_posix.h +++ b/unix/povconfig/syspovconfig_posix.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -39,29 +39,13 @@ #ifndef POVRAY_UNIX_SYSPOVCONFIG_POSIX_H #define POVRAY_UNIX_SYSPOVCONFIG_POSIX_H -#include +#include // Pulled in for `off_t`. +#include // Pulled in for `_POSIX_V6_xxx`. -#if defined(_POSIX_V6_LPBIG_OFFBIG) || defined(_POSIX_V6_LP64_OFF64) || defined(_POSIX_V6_ILP32_OFFBIG) - // `off_t` is at least 64 bits. - // This variant of Unix provides large file support via the `lseek` function, - // with file offsets having type `off_t`. - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#elif defined(_POSIX_V6_ILP32_OFF32) - // `off_t` is at least 32 bits. - // This variant of Unix does _not_ provide large file support via the `lseek` function. - // Comment-out the following line to proceed anyway. - #error "Image size will be limited to approx. 100 Megapixels. Proceed at your own risk." - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#else - // Unable to detect `off_t` size at compile-time. - // This variant of Unix _may or may not_ provide large file support via the `lseek` function. - // Comment-out the following line to proceed anyway - #error "Image size may be limited to approx. 100 Megapixels. Proceed at your own risk." - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#endif +// POSIX does not provide an explicit 64-bit `lseek`, so we're stuck with +// whatever size `off_t` happens to have. +#define POVUNIX_LSEEK64(h,o,w) lseek(h,o,w) +#define POV_OFF_T off_t #if defined(_POSIX_V6_LPBIG_OFFBIG) || defined(_POSIX_V6_LP64_OFF64) // long is at least 64 bits. diff --git a/unix/povconfig/syspovconfigbase.h b/unix/povconfig/syspovconfigbase.h index 2605730d2..30ad78f2b 100644 --- a/unix/povconfig/syspovconfigbase.h +++ b/unix/povconfig/syspovconfigbase.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -42,7 +42,6 @@ #include "syspovconfig.h" #define POV_PATH_SEPARATOR '/' -#define IFF_SWITCH_CAST (long) // Our Unix-specific implementation of the Delay() function currently relies on the presence of // the nanosleep() or usleep() functions. If we have neither of those, we're falling back to @@ -68,4 +67,10 @@ // The default Path::ParsePathString() suits our needs perfectly. #define POV_USE_DEFAULT_PATH_PARSER 1 +// We want to implement a specialized Filesystem::DeleteFile. +#define POV_USE_DEFAULT_DELETEFILE 0 + +// We want to implement a specialized Filesystem::LargeFile. +#define POV_USE_DEFAULT_LARGEFILE 0 + #endif // POVRAY_UNIX_SYSPOVCONFIGBASE_H diff --git a/vfe/unix/unixconsole.cpp b/vfe/unix/unixconsole.cpp index 7d821f5a3..8acb6c37f 100644 --- a/vfe/unix/unixconsole.cpp +++ b/vfe/unix/unixconsole.cpp @@ -37,6 +37,10 @@ #include #include +// C++ standard header files +#include +#include + // Other library header files #include #include @@ -56,8 +60,9 @@ namespace pov_frontend { - shared_ptr gDisplay; + std::shared_ptr gDisplay; } +// end of namespace pov_frontend using namespace vfe; using namespace vfePlatform; @@ -174,7 +179,7 @@ static void PrintStatus (vfeSession *session) // TODO -- when invoked while processing "--help" command-line switch, // GNU/Linux customs would be to print to stdout (among other differences). - string str; + std::string str; vfeSession::MessageType type; static vfeSession::MessageType lastType = vfeSession::mUnclassified; @@ -303,12 +308,12 @@ static void PauseWhenDone(vfeSession *session) GetRenderWindow()->PauseWhenDoneNotifyEnd(); } -static ReturnValue PrepareBenchmark(vfeSession *session, vfeRenderOptions& opts, string& ini, string& pov, int argc, char **argv) +static ReturnValue PrepareBenchmark(vfeSession *session, vfeRenderOptions& opts, std::string& ini, std::string& pov, int argc, char **argv) { // parse command-line options while (*++argv) { - string s = string(*argv); + std::string s = std::string(*argv); boost::to_lower(s); // set number of threads to run the benchmark if (boost::starts_with(s, "+wt") || boost::starts_with(s, "-wt")) @@ -372,7 +377,7 @@ Press to continue or to abort.\n\ Delay(20); } - string basename = UCS2toSysString(session->CreateTemporaryFile()); + std::string basename = UCS2toSysString(session->CreateTemporaryFile()); ini = basename + ".ini"; pov = basename + ".pov"; if (pov::Write_Benchmark_File(pov.c_str(), ini.c_str())) @@ -390,7 +395,7 @@ Press to continue or to abort.\n\ return RETURN_OK; } -static void CleanupBenchmark(vfeUnixSession *session, string& ini, string& pov) +static void CleanupBenchmark(vfeUnixSession *session, std::string& ini, std::string& pov) { fprintf(stderr, "%s: removing %s\n", PACKAGE, ini.c_str()); session->DeleteTemporaryFile(SysToUCS2String(ini.c_str())); @@ -405,8 +410,8 @@ int main (int argc, char **argv) vfeRenderOptions opts; ReturnValue retval = RETURN_OK; bool running_benchmark = false; - string bench_ini_name; - string bench_pov_name; + std::string bench_ini_name; + std::string bench_pov_name; sigset_t sigset; boost::thread *sigthread; char ** argv_copy=argv; /* because argv is updated later */ @@ -512,7 +517,7 @@ int main (int argc, char **argv) if (running_benchmark) { // read only the provided INI file and set minimal lib paths - opts.AddLibraryPath(string(POVLIBDIR "/include")); + opts.AddLibraryPath(std::string(POVLIBDIR "/include")); opts.AddINI(bench_ini_name.c_str()); opts.SetSourceFile(bench_pov_name.c_str()); } diff --git a/vfe/unix/unixoptions.cpp b/vfe/unix/unixoptions.cpp index 7cec5d485..5a73b65b6 100644 --- a/vfe/unix/unixoptions.cpp +++ b/vfe/unix/unixoptions.cpp @@ -12,7 +12,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -44,6 +44,7 @@ // C++ standard header files #include +#include // Boost header files #include @@ -56,6 +57,8 @@ namespace vfePlatform { using std::cerr; using std::endl; + using std::string; + using std::list; extern bool gShelloutsPermittedFixThis; @@ -332,10 +335,10 @@ namespace vfePlatform nargv[nargc] = nullptr; - vector CmdVariations; + std::vector CmdVariations; boost::split(CmdVariations, (*iter).CmdOption, boost::is_any_of("|")); - for (vector::iterator iter_c = CmdVariations.begin(); iter_c != CmdVariations.end(); iter_c++) + for (std::vector::iterator iter_c = CmdVariations.begin(); iter_c != CmdVariations.end(); iter_c++) { for (int i = 1; i < nargc;) { @@ -513,7 +516,7 @@ namespace vfePlatform string UnixOptionsProcessor::CanonicalizePath(const string &path) { int i; - typedef struct { const char *match, *replace; } subst; + struct subst final { const char *match, *replace; }; const subst strings[] = { // beware: order does matter { "%INSTALLDIR%", POVLIBDIR }, { "%HOME%", m_home.c_str() }, @@ -720,7 +723,7 @@ namespace vfePlatform typedef enum { NONE, FILE_IO, SHELLOUT, PERMITTED_PATHS, UNKNOWN } SectionVal; SectionVal section; - typedef struct Section { const char *label; const SectionVal value; } Section; + struct Section final { const char *label; const SectionVal value; }; const Section sections[] = { { "" , NONE }, // init @@ -730,7 +733,7 @@ namespace vfePlatform { nullptr , UNKNOWN } // sentinel }; - typedef struct IOSettings { const char *label; const FileIO value; } IOSettings; + struct IOSettings final { const char *label; const FileIO value; }; const IOSettings io_settings[] = { { "" , IO_UNSET }, @@ -740,7 +743,7 @@ namespace vfePlatform { nullptr , IO_UNKNOWN } }; - typedef struct SHLSettings { const char *label; const ShellOut value; } SHLSettings; + struct SHLSettings final { const char *label; const ShellOut value; }; const SHLSettings shl_settings[] = { { "" , SHL_UNSET }, @@ -1227,3 +1230,4 @@ namespace vfePlatform } } +// end of namespace vfePlatform diff --git a/vfe/unix/unixoptions.h b/vfe/unix/unixoptions.h index 28099df4d..452c1a9b9 100644 --- a/vfe/unix/unixoptions.h +++ b/vfe/unix/unixoptions.h @@ -12,7 +12,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -43,7 +43,6 @@ #include "vfe.h" #include -#include #include #include #include @@ -142,10 +141,10 @@ namespace vfePlatform /// permission path for IO restrictions settings struct UnixPath { - string str; + std::string str; bool descend, writable; - UnixPath(const string &s, bool desc = false, bool wrt = false) : str(s), descend(desc), writable(wrt) { } + UnixPath(const std::string &s, bool desc = false, bool wrt = false) : str(s), descend(desc), writable(wrt) { } }; /** @@ -155,11 +154,11 @@ namespace vfePlatform */ struct Conf_Option { - string Section; - string Name; - string Value; + std::string Section; + std::string Name; + std::string Value; - Conf_Option(const string &Sect, const string &Nm, const string &Val = "") : Section(Sect), Name(Nm), Value(Val) { } + Conf_Option(const std::string &Sect, const std::string &Nm, const std::string &Val = "") : Section(Sect), Name(Nm), Value(Val) { } }; /** @@ -174,21 +173,21 @@ namespace vfePlatform */ struct Option_Info { - string Section; - string Name; - string Value; - string CmdOption; - string EnvVariable; - string Comment; + std::string Section; + std::string Name; + std::string Value; + std::string CmdOption; + std::string EnvVariable; + std::string Comment; bool has_param; - Option_Info(const string &Sect , - const string &Nm, - const string &Val = "", - bool par = false, - const string &Cmd = "", - const string &Env = "", - const string &Comm = "") + Option_Info(const std::string &Sect , + const std::string &Nm, + const std::string &Val = "", + bool par = false, + const std::string &Cmd = "", + const std::string &Env = "", + const std::string &Comm = "") : Section(Sect), Name(Nm), Value(Val), has_param(par), CmdOption(Cmd), EnvVariable(Env), Comment(Comm) { } /// only checks identity of the option, not of the selected value. @@ -223,7 +222,7 @@ namespace vfePlatform Converts a file path to standard form replacing relative notations. */ - string CanonicalizePath(const string &path); + std::string CanonicalizePath(const std::string &path); /** Finds out the default location for temporary files. @@ -231,7 +230,7 @@ namespace vfePlatform @returns temporary path including a trailing slash */ - string GetTemporaryPath(void); + std::string GetTemporaryPath(void); /** Finds the value of a certain option from @@ -249,7 +248,7 @@ namespace vfePlatform section and option name and returns it as a string. */ - string QueryOptionString(const string §ion, const string &name); + std::string QueryOptionString(const std::string §ion, const std::string &name); /** Finds the value of a certain option via @@ -257,7 +256,7 @@ namespace vfePlatform an int. If the options value is not convertible to int dflt is returned instead. */ - int QueryOptionInt(const string §ion, const string &name, const int dflt = 0); + int QueryOptionInt(const std::string §ion, const std::string &name, const int dflt = 0); /** Finds the value of a certain option via @@ -265,7 +264,7 @@ namespace vfePlatform a float If the options value is not convertible to float dflt is returned instead. */ - float QueryOptionFloat(const string §ion, const string &name, const float dflt = 0.0); + float QueryOptionFloat(const std::string §ion, const std::string &name, const float dflt = 0.0); /** Check if a certain option has been set @@ -275,7 +274,7 @@ namespace vfePlatform @returns true if set, false otherwise */ bool isOptionSet(const Option_Info &option); - bool isOptionSet(const string §ion, const string &name); + bool isOptionSet(const std::string §ion, const std::string &name); /** Adds the custom povray.conf options with their values @@ -315,39 +314,40 @@ namespace vfePlatform @param write If write acccess was requested @param is_user_setting if denial was due to user setting */ - void IORestrictionsError(const string &fnm, bool write, bool is_user_setting); + void IORestrictionsError(const std::string &fnm, bool write, bool is_user_setting); - bool ShelloutPermitted(const string& command, const string& parameters) const { return m_shellout == SHL_ALLOWED; } + bool ShelloutPermitted(const std::string& command, const std::string& parameters) const { return m_shellout == SHL_ALLOWED; } protected: /// list of standard options static const Option_Info Standard_Options[]; - string unix_getcwd(void); - string basename(const string &path); - string dirname(const string &path); - string unix_readlink(const string &path); - string pre_process_conf_line(const string &input); - void add_permitted_path(list &paths, const string &input, const string &conf_name, unsigned long line_number); - void parse_conf_file(std::istream &Stream, const string &conf_name, bool user_mode); + std::string unix_getcwd(void); + std::string basename(const std::string &path); + std::string dirname(const std::string &path); + std::string unix_readlink(const std::string &path); + std::string pre_process_conf_line(const std::string &input); + void add_permitted_path(std::list &paths, const std::string &input, const std::string &conf_name, unsigned long line_number); + void parse_conf_file(std::istream &Stream, const std::string &conf_name, bool user_mode); void process_povray_conf(void); void remove_arg(int *argc, char *argv[], int index); - bool file_exist(const string &name); + bool file_exist(const std::string &name); vfeSession *m_Session; - string m_home; - string m_user_dir; - string m_sysconf; // system conf filename - string m_userconf; // user conf filename - string m_conf; // selected conf file - string m_sysini, m_sysini_old; // system ini filename - string m_userini, m_userini_old; // user ini filename + std::string m_home; + std::string m_user_dir; + std::string m_sysconf; // system conf filename + std::string m_userconf; // user conf filename + std::string m_conf; // selected conf file + std::string m_sysini, m_sysini_old; // system ini filename + std::string m_userini, m_userini_old; // user ini filename FileIO m_file_io; ShellOut m_shellout; - list m_permitted_paths; - list m_custom_conf_options; - list m_user_options; + std::list m_permitted_paths; + std::list m_custom_conf_options; + std::list m_user_options; }; } +// end of namespace vfePlatform #endif // POVRAY_VFE_UNIX_UNIXOPTIONS_H diff --git a/vfe/unix/vfeplatform.cpp b/vfe/unix/vfeplatform.cpp index 828270c58..daf1382d9 100644 --- a/vfe/unix/vfeplatform.cpp +++ b/vfe/unix/vfeplatform.cpp @@ -38,7 +38,7 @@ // must come first, will pull in "config.h" for HAVE_* macros #include "syspovconfig.h" -// C++ variants of C standard headers +// C++ variants of C standard header files #include #include #include @@ -46,7 +46,11 @@ # include #endif -// other library headers +// C++ standard header files +#include +#include + +// other library header files #include #ifdef HAVE_SYS_TIME_H # include @@ -59,6 +63,9 @@ #include "vfe.h" #include "unix/unixoptions.h" +#include "base/filesystem.h" +#include "syspovfilesystem.h" + namespace vfePlatform { using namespace vfe; @@ -80,7 +87,8 @@ namespace vfePlatform vfeUnixSession::vfeUnixSession(int id) : m_LastTimestamp(0), m_TimestampOffset(0), vfeSession(id) { - m_OptionsProc = shared_ptr(new UnixOptionsProcessor(this)); + m_OptionsProc = std::shared_ptr(new UnixOptionsProcessor(this)); + pov_base::Filesystem::SetTempFilePath(SysToUCS2String(m_OptionsProc->GetTemporaryPath())); } ///////////////////////////////////////////////////////////////////////// @@ -122,7 +130,7 @@ namespace vfePlatform // error will occur again (e.g. invalid output path or something), then // you may want to call the render cancel API so the user isn't bombarded // with an error message for each frame of the render. - int vfeUnixSession::RequestNewOutputPath(int CallCount, const string& Reason, const UCS2String& OldPath, UCS2String& NewPath) + int vfeUnixSession::RequestNewOutputPath(int CallCount, const std::string& Reason, const UCS2String& OldPath, UCS2String& NewPath) { // TODO: print warning and cancel? return 0; @@ -146,12 +154,9 @@ namespace vfePlatform // name to one that it can use. UCS2String vfeUnixSession::CreateTemporaryFile(void) const { - // TODO FIXME - This allows only one temporary file per process! - char str [POV_FILENAME_BUFFER_CHARS+1] = ""; - std::snprintf(str, sizeof(str), "%spov%d", m_OptionsProc->GetTemporaryPath().c_str(), getpid ()); - POV_DELETE_FILE (str); - - return SysToUCS2String(str); + pov_base::Filesystem::TemporaryFilePtr tempFile(new pov_base::Filesystem::TemporaryFile); + m_TempFiles.push_back(tempFile); + return tempFile->GetFileName(); } ///////////////////////////////////////////////////////////////////////// @@ -160,7 +165,7 @@ namespace vfePlatform // example doesn't do that but it's not a bad idea to add. void vfeUnixSession::DeleteTemporaryFile(const UCS2String& filename) const { - POV_DELETE_FILE (UCS2toSysString (filename).c_str()); + pov_base::Filesystem::DeleteFile(filename); } ////////////////////////////////////////////////////////////// @@ -268,8 +273,8 @@ namespace vfePlatform if (StrCompare(path.GetVolume(), file.GetVolume()) == false) return (false); - vector pc = path.GetAllFolders(); - vector fc = file.GetAllFolders(); + std::vector pc = path.GetAllFolders(); + std::vector fc = file.GetAllFolders(); if (fc.size() < pc.size()) return (false) ; for (int i = 0 ; i < pc.size(); i++) @@ -289,7 +294,7 @@ namespace vfePlatform if (!m_OptionsProc->isIORestrictionsEnabled(isWrite)) return true; - string FullFnm = m_OptionsProc->CanonicalizePath(UCS2toSysString(file())); + std::string FullFnm = m_OptionsProc->CanonicalizePath(UCS2toSysString(file())); if(FullFnm.length() == 0) return false; @@ -333,7 +338,7 @@ namespace vfePlatform // on the requirements for these methods. ///////////////////////////////////////////////////////////////////////////// - UnixShelloutProcessing::UnixShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height): ShelloutProcessing(opts, scene, width, height) + UnixShelloutProcessing::UnixShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height): ShelloutProcessing(opts, scene, width, height) { m_ProcessRunning = false; m_ProcessId = m_LastError = m_ExitCode = 0; @@ -346,7 +351,7 @@ namespace vfePlatform CollectCommand(); } - bool UnixShelloutProcessing::ExecuteCommand(const string& cmd, const string& params) + bool UnixShelloutProcessing::ExecuteCommand(const std::string& cmd, const std::string& params) { #if 0 if (UnixShelloutProcessing::CommandRunning()) @@ -365,7 +370,7 @@ namespace vfePlatform m_Params = params; m_ProcessId = m_LastError = m_ExitCode = 0; - string command = cmd + " " + params; + std::string command = cmd + " " + params; boost::trim(command); if (command.empty()) throw POV_EXCEPTION(kParamErr, "Empty shellout command"); @@ -420,19 +425,20 @@ namespace vfePlatform return m_ExitCode; } - int UnixShelloutProcessing::CollectCommand(string& output) + int UnixShelloutProcessing::CollectCommand(std::string& output) { // TODO: IMPLEMENT IF OUTPUT COLLECTION TO BE SUPPORTED return CollectCommand(); } - bool UnixShelloutProcessing::CommandPermitted(const string& command, const string& parameters) + bool UnixShelloutProcessing::CommandPermitted(const std::string& command, const std::string& parameters) { // until we get a unix support guy, this is just a hack: use a global - string cmd = command + " " + parameters; + std::string cmd = command + " " + parameters; boost::trim(cmd); if (command.empty() || *command.rbegin() == '&') return false; return gShelloutsPermittedFixThis; } } +// end of namespace vfePlatform diff --git a/vfe/unix/vfeplatform.h b/vfe/unix/vfeplatform.h index 866370dd7..0be3da362 100644 --- a/vfe/unix/vfeplatform.h +++ b/vfe/unix/vfeplatform.h @@ -38,10 +38,13 @@ #ifndef POVRAY_VFE_UNIX_VFEPLATFORM_H #define POVRAY_VFE_UNIX_VFEPLATFORM_H +#include + #include -#include "base/path.h" -#include "base/stringutilities.h" +#include "base/path_fwd.h" +#include "base/stringtypes.h" +#include "base/filesystem_fwd.h" #include "frontend/shelloutprocessing.h" @@ -57,29 +60,30 @@ namespace vfePlatform class UnixShelloutProcessing: public pov_frontend::ShelloutProcessing { public: - UnixShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height); - virtual ~UnixShelloutProcessing(); + UnixShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height); + virtual ~UnixShelloutProcessing() override; - virtual int ProcessID(void); - virtual bool ShelloutsSupported(void) { return true; } + virtual int ProcessID(void) override; + virtual bool ShelloutsSupported(void) override { return true; } protected: - virtual bool ExecuteCommand(const string& cmd, const string& params); - virtual bool KillCommand(int timeout, bool force = false); - virtual bool CommandRunning(void); - virtual int CollectCommand(string& output); - virtual int CollectCommand(void); - virtual bool CommandPermitted(const string& command, const string& parameters); + virtual bool ExecuteCommand(const std::string& cmd, const std::string& params) override; + virtual bool KillCommand(int timeout, bool force = false) override; + virtual bool CommandRunning(void) override; + virtual int CollectCommand(std::string& output) override; + virtual int CollectCommand(void) override; + virtual bool CommandPermitted(const std::string& command, const std::string& parameters) override; bool m_ProcessRunning; - string m_Command; - string m_Params; + std::string m_Command; + std::string m_Params; unsigned long m_ExitCode; unsigned long m_LastError; unsigned long m_ProcessId; private: - UnixShelloutProcessing(); + + UnixShelloutProcessing() = delete; }; /////////////////////////////////////////////////////////////////////// @@ -89,23 +93,23 @@ namespace vfePlatform { public: vfeUnixSession(int id = 0); - virtual ~vfeUnixSession() {} - - virtual UCS2String GetTemporaryPath(void) const; - virtual UCS2String CreateTemporaryFile(void) const; - virtual void DeleteTemporaryFile(const UCS2String& filename) const; - virtual POV_LONG GetTimestamp(void) const ; - virtual void NotifyCriticalError(const char *message, const char *file, int line); - virtual int RequestNewOutputPath(int CallCount, const string& Reason, const UCS2String& OldPath, UCS2String& NewPath); - virtual bool TestAccessAllowed(const Path& file, bool isWrite) const; - virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height) + virtual ~vfeUnixSession() override {} + + virtual UCS2String GetTemporaryPath(void) const override; + virtual UCS2String CreateTemporaryFile(void) const override; + virtual void DeleteTemporaryFile(const UCS2String& filename) const override; + virtual POV_LONG GetTimestamp(void) const override; + virtual void NotifyCriticalError(const char *message, const char *file, int line) override; + virtual int RequestNewOutputPath(int CallCount, const std::string& Reason, const UCS2String& OldPath, UCS2String& NewPath) override; + virtual bool TestAccessAllowed(const Path& file, bool isWrite) const override; + virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height) override { return new UnixShelloutProcessing(opts, scene, width, height); } - shared_ptr GetUnixOptions(void) { return m_OptionsProc; } + std::shared_ptr GetUnixOptions(void) { return m_OptionsProc; } protected: - virtual void WorkerThreadStartup(); - virtual void WorkerThreadShutdown(); + virtual void WorkerThreadStartup() override; + virtual void WorkerThreadShutdown() override; /////////////////////////////////////////////////////////////////////// // return true if the path component of file is equal to the path component @@ -127,7 +131,10 @@ namespace vfePlatform mutable POV_LONG m_TimestampOffset; // platform specific configuration options - shared_ptr m_OptionsProc; + std::shared_ptr m_OptionsProc; + + // Temporary files to be deleted when session closes. + mutable std::vector m_TempFiles; } ; /////////////////////////////////////////////////////////////////////// @@ -135,5 +142,6 @@ namespace vfePlatform // all other running threads in the process (and preferably in the OS). POVMS_Sys_Thread_Type GetThreadId(); } +// end of namespace vfePlatform #endif // POVRAY_VFE_UNIX_VFEPLATFORM_H diff --git a/vfe/vfe.cpp b/vfe/vfe.cpp index 5c3811d28..ab97f6336 100644 --- a/vfe/vfe.cpp +++ b/vfe/vfe.cpp @@ -45,6 +45,10 @@ #include #include +#include "base/filesystem.h" +#include "base/povassert.h" +#include "base/textstream.h" + #include "frontend/animationprocessing.h" #include "frontend/imageprocessing.h" @@ -57,11 +61,12 @@ namespace vfe using namespace pov_base; using namespace pov_frontend; using boost::format; +using std::shared_ptr; +using std::string; static int Allow_File_Read(const UCS2 *Filename, const unsigned int FileType); static int Allow_File_Write(const UCS2 *Filename, const unsigned int FileType); static FILE *vfeFOpen(const UCS2String& name, const char *mode); -static bool vfeRemove(const UCS2String& name); //////////////////////////////////////////////////////////////////////////////////////// // @@ -132,7 +137,7 @@ class ParseWarningDetails : public POVMSMessageDetails { public: ParseWarningDetails (POVMS_Object &Obj) : POVMSMessageDetails (Obj) {} ; - virtual ~ParseWarningDetails () {} ; + virtual ~ParseWarningDetails () override {} ; public: using POVMSMessageDetails::File ; @@ -147,7 +152,7 @@ class ParseErrorDetails : public POVMSMessageDetails { public: ParseErrorDetails (POVMS_Object &Obj) : POVMSMessageDetails (Obj) {} ; - virtual ~ParseErrorDetails () {} ; + virtual ~ParseErrorDetails () override {} ; public: using POVMSMessageDetails::File ; @@ -264,11 +269,6 @@ FILE* vfePlatformBase::OpenLocalFile (const UCS2String& name, const char *mode) return vfeFOpen (name, mode); } -void vfePlatformBase::DeleteLocalFile (const UCS2String& name) -{ - vfeRemove (name); -} - bool vfePlatformBase::AllowLocalFileAccess (const UCS2String& name, const unsigned int fileType, bool write) { if (write) @@ -1412,10 +1412,5 @@ FILE *vfeFOpen (const UCS2String& name, const char *mode) return (fopen (UCS2toSysString (name).c_str(), mode)) ; } -bool vfeRemove(const UCS2String& Filename) -{ - return (POV_DELETE_FILE (UCS2toSysString (Filename).c_str()) == 0); -} - } - +// end of namespace vfe diff --git a/vfe/vfe.h b/vfe/vfe.h index f3ca10708..92602a650 100644 --- a/vfe/vfe.h +++ b/vfe/vfe.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,18 +38,20 @@ #ifndef POVRAY_VFE_VFE_H #define POVRAY_VFE_VFE_H -#include +#include +#include #include #include #include -#include "povms/povmscpp.h" -#include "povms/povmsid.h" - #include "base/platformbase.h" +#include "base/stringtypes.h" #include "base/timer.h" +#include "povms/povmscpp.h" +#include "povms/povmsid.h" + #include "frontend/console.h" #include "frontend/display.h" #include "frontend/filemessagehandler.h" @@ -68,46 +70,46 @@ namespace vfe { using namespace pov_frontend; - class vfeException : public runtime_error + class vfeException : public std::runtime_error { public: - vfeException() : runtime_error("") {} - vfeException(const string str) : runtime_error(str) {} - virtual ~vfeException() throw() {} + vfeException() : std::runtime_error("") {} + vfeException(const std::string str) : std::runtime_error(str) {} + virtual ~vfeException() throw() override {} } ; class vfeCriticalError : public vfeException { public: vfeCriticalError() : m_Line(0), vfeException() {} - vfeCriticalError(const string str) : m_Line(0), vfeException(str) {} - vfeCriticalError(const string str, const string filename, int line) : + vfeCriticalError(const std::string str) : m_Line(0), vfeException(str) {} + vfeCriticalError(const std::string str, const std::string filename, int line) : vfeException(str), m_Filename(filename), m_Line(line) {} - virtual ~vfeCriticalError() throw() {} + virtual ~vfeCriticalError() throw() override {} - const string Filename() { return m_Filename; } + const std::string Filename() { return m_Filename; } int Line() { return m_Line; } - const string m_Filename; + const std::string m_Filename; const int m_Line; }; class vfeInvalidDataError : public vfeCriticalError { public: - vfeInvalidDataError(const string str) : vfeCriticalError(str) {} - virtual ~vfeInvalidDataError() throw() {} + vfeInvalidDataError(const std::string str) : vfeCriticalError(str) {} + virtual ~vfeInvalidDataError() throw() override {} }; class vfeConsole : public Console { public: vfeConsole(vfeSession *session, int width = -1); - virtual ~vfeConsole(); + virtual ~vfeConsole() override; - virtual void Initialise(); - virtual void Output(const string&); - virtual void Output(const string&, vfeSession::MessageType mType); + virtual void Initialise() override; + virtual void Output(const std::string&) override; + virtual void Output(const std::string&, vfeSession::MessageType mType); virtual void Output(const char *str, vfeSession::MessageType mType = vfeSession::mUnclassified); virtual void BufferOutput(const char *str, unsigned int chars = 0, vfeSession::MessageType mType = vfeSession::mUnclassified); @@ -123,15 +125,14 @@ namespace vfe public: vfePlatformBase(); vfePlatformBase(vfeSession& session); - virtual ~vfePlatformBase(); + virtual ~vfePlatformBase() override; - virtual UCS2String GetTemporaryPath(void); - virtual UCS2String CreateTemporaryFile(void); - virtual void DeleteTemporaryFile(const UCS2String& filename); - virtual bool ReadFileFromURL(OStream *file, const UCS2String& url, const UCS2String& referrer = UCS2String()); - virtual FILE* OpenLocalFile (const UCS2String& name, const char *mode); - virtual void DeleteLocalFile (const UCS2String& name); - virtual bool AllowLocalFileAccess (const UCS2String& name, const unsigned int fileType, bool write); + virtual UCS2String GetTemporaryPath() override; + virtual UCS2String CreateTemporaryFile() override; + virtual void DeleteTemporaryFile(const UCS2String& name) override; + virtual bool ReadFileFromURL(OStream *file, const UCS2String& url, const UCS2String& referrer = UCS2String()) override; + virtual FILE* OpenLocalFile (const UCS2String& name, const char *mode) override; + virtual bool AllowLocalFileAccess (const UCS2String& name, const unsigned int fileType, bool write) override; protected: vfeSession* m_Session; @@ -141,16 +142,16 @@ namespace vfe { public: vfeParserMessageHandler(); - virtual ~vfeParserMessageHandler(); + virtual ~vfeParserMessageHandler() override; protected: - virtual void Options(Console *, POVMS_Object&, bool); - virtual void Statistics(Console *, POVMS_Object&, bool); - virtual void Progress(Console *, POVMS_Object&, bool); - virtual void Warning(Console *, POVMS_Object&, bool); - virtual void Error(Console *, POVMS_Object&, bool); - virtual void FatalError(Console *, POVMS_Object&, bool); - virtual void DebugInfo(Console *, POVMS_Object&, bool); + virtual void Options(Console *, POVMS_Object&, bool) override; + virtual void Statistics(Console *, POVMS_Object&, bool) override; + virtual void Progress(Console *, POVMS_Object&, bool) override; + virtual void Warning(Console *, POVMS_Object&, bool) override; + virtual void Error(Console *, POVMS_Object&, bool) override; + virtual void FatalError(Console *, POVMS_Object&, bool) override; + virtual void DebugInfo(Console *, POVMS_Object&, bool) override; vfeSession* m_Session; }; @@ -159,15 +160,15 @@ namespace vfe { public: vfeRenderMessageHandler(); - virtual ~vfeRenderMessageHandler(); + virtual ~vfeRenderMessageHandler() override; protected: - virtual void Options(Console *, POVMS_Object&, bool); - virtual void Statistics(Console *, POVMS_Object&, bool); - virtual void Progress(Console *, POVMS_Object&, bool); - virtual void Warning(Console *, POVMS_Object&, bool); - virtual void Error(Console *, POVMS_Object&, bool); - virtual void FatalError(Console *, POVMS_Object&, bool); + virtual void Options(Console *, POVMS_Object&, bool) override; + virtual void Statistics(Console *, POVMS_Object&, bool) override; + virtual void Progress(Console *, POVMS_Object&, bool) override; + virtual void Warning(Console *, POVMS_Object&, bool) override; + virtual void Error(Console *, POVMS_Object&, bool) override; + virtual void FatalError(Console *, POVMS_Object&, bool) override; vfeSession *m_Session; }; @@ -176,18 +177,18 @@ namespace vfe { public: vfeProcessRenderOptions(vfeSession *); - virtual ~vfeProcessRenderOptions(); + virtual ~vfeProcessRenderOptions() override; protected: - virtual int ReadSpecialOptionHandler(INI_Parser_Table *, char *, POVMSObjectPtr); - virtual int ReadSpecialSwitchHandler(Cmd_Parser_Table *, char *, POVMSObjectPtr, bool); - virtual int WriteSpecialOptionHandler(INI_Parser_Table *, POVMSObjectPtr, OTextStream *); - virtual int ProcessUnknownString(char *, POVMSObjectPtr); - virtual ITextStream *OpenFileForRead(const char *, POVMSObjectPtr); - virtual OTextStream *OpenFileForWrite(const char *, POVMSObjectPtr); - virtual void ParseError (const char *, ...); - virtual void ParseErrorAt (ITextStream *, const char *, ...); - virtual void WriteError (const char *, ...); + virtual int ReadSpecialOptionHandler(INI_Parser_Table *, char *, POVMSObjectPtr) override; + virtual int ReadSpecialSwitchHandler(Cmd_Parser_Table *, char *, POVMSObjectPtr, bool) override; + virtual int WriteSpecialOptionHandler(INI_Parser_Table *, POVMSObjectPtr, OTextStream *) override; + virtual int ProcessUnknownString(char *, POVMSObjectPtr) override; + virtual ITextStream *OpenFileForRead(const char *, POVMSObjectPtr) override; + virtual OTextStream *OpenFileForWrite(const char *, POVMSObjectPtr) override; + virtual void ParseError (const char *, ...) override; + virtual void ParseErrorAt (ITextStream *, const char *, ...) override; + virtual void WriteError (const char *, ...) override; protected: vfeSession* m_Session; @@ -197,41 +198,41 @@ namespace vfe { public: vfeDisplay(unsigned int width, unsigned int height, vfeSession *session, bool visible = false); - virtual ~vfeDisplay(); + virtual ~vfeDisplay() override; - virtual void Initialise(); + virtual void Initialise() override; virtual void Close(); virtual void Show(); virtual void Hide(); - virtual void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour); - virtual void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - virtual void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - virtual void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour); - virtual void Clear(); + virtual void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour) override; + virtual void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + virtual void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + virtual void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour) override; + virtual void Clear() override; protected: vfeSession *m_Session; - vector m_Pixels; + std::vector m_Pixels; bool m_VisibleOnCreation; }; class VirtualFrontEnd { public: - VirtualFrontEnd(vfeSession& session, POVMSContext ctx, POVMSAddress addr, POVMS_Object& msg, POVMS_Object *result, shared_ptr& console) ; - virtual ~VirtualFrontEnd() ; - - virtual bool Start(POVMS_Object& opts) ; - virtual bool Stop() ; - virtual bool Pause() ; - virtual bool Resume() ; - virtual State Process() ; + VirtualFrontEnd(vfeSession& session, POVMSContext ctx, POVMSAddress addr, POVMS_Object& msg, POVMS_Object *result, std::shared_ptr& console) ; + virtual ~VirtualFrontEnd(); + + virtual bool Start(POVMS_Object& opts); + virtual bool Stop(); + virtual bool Pause(); + virtual bool Resume(); + virtual State Process(); virtual State GetState() const { return state; } - virtual void SetResultPointers(Console **cr, Image **ir, Display **dr) ; - virtual bool IsPausable() ; - virtual bool Paused() ; + virtual void SetResultPointers(Console **cr, Image **ir, Display **dr); + virtual bool IsPausable(); + virtual bool Paused(); virtual bool PausePending() { return m_PauseRequested; } - virtual shared_ptr GetDisplay() { return renderFrontend.GetDisplay(viewId); } + virtual std::shared_ptr GetDisplay() { return renderFrontend.GetDisplay(viewId); } // TODO: take care of any pending messages (e.g. a thread waiting on a blocking send) virtual void InvalidateBackend() { backendAddress = POVMSInvalidAddress; } @@ -249,9 +250,9 @@ namespace vfe POVMS_Object options; RenderFrontendBase::SceneId sceneId; RenderFrontendBase::ViewId viewId; - shared_ptr animationProcessing ; - shared_ptr imageProcessing ; - shared_ptr shelloutProcessing; + std::shared_ptr animationProcessing ; + std::shared_ptr imageProcessing ; + std::shared_ptr shelloutProcessing; Console **consoleResult; Display **displayResult; vfeSession* m_Session; @@ -261,5 +262,6 @@ namespace vfe State m_PostPauseState; }; } +// end of namespace vfe #endif // POVRAY_VFE_VFE_H diff --git a/vfe/vfeconf.h b/vfe/vfeconf.h index 5f6641691..fbb906130 100644 --- a/vfe/vfeconf.h +++ b/vfe/vfeconf.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -44,25 +44,22 @@ #define POVMS_Sys_Thread_Type unsigned long -#include -#include - namespace vfe { - typedef class SysQNode POVMS_Sys_QueueNode ; - void* /*POVMSAddress*/ vfe_POVMS_Sys_QueueToAddress (POVMS_Sys_QueueNode *q) ; - POVMS_Sys_QueueNode *vfe_POVMS_Sys_AddressToQueue (void* /*POVMSAddress*/ a) ; - POVMS_Sys_QueueNode *vfe_POVMS_Sys_QueueOpen (void) ; - void vfe_POVMS_Sys_QueueClose (POVMS_Sys_QueueNode *q) ; - void *vfe_POVMS_Sys_QueueReceive (POVMS_Sys_QueueNode *q, int *l, bool, bool) ; - int vfe_POVMS_Sys_QueueSend(POVMS_Sys_QueueNode *q, void *p, int l) ; + class SysQNode; + void* /*POVMSAddress*/ vfe_POVMS_Sys_QueueToAddress (SysQNode *q) ; + SysQNode *vfe_POVMS_Sys_AddressToQueue (void* /*POVMSAddress*/ a) ; + SysQNode *vfe_POVMS_Sys_QueueOpen (void) ; + void vfe_POVMS_Sys_QueueClose (SysQNode *q) ; + void *vfe_POVMS_Sys_QueueReceive (SysQNode *q, int *l, bool, bool) ; + int vfe_POVMS_Sys_QueueSend(SysQNode *q, void *p, int l) ; POVMS_Sys_Thread_Type POVMS_GetCurrentThread(); void vfeAssert (const char *message, const char *filename, int line) ; } +// end of namespace vfe #define POVMS_ASSERT_OUTPUT vfe::vfeAssert -#define POVMS_Sys_Queue_Type vfe::POVMS_Sys_QueueNode * -#define POVMS_Sys_Queue_Type vfe::POVMS_Sys_QueueNode * +#define POVMS_Sys_Queue_Type vfe::SysQNode * #define POVMS_Sys_QueueToAddress vfe::vfe_POVMS_Sys_QueueToAddress #define POVMS_Sys_AddressToQueue vfe::vfe_POVMS_Sys_AddressToQueue #define POVMS_Sys_QueueOpen vfe::vfe_POVMS_Sys_QueueOpen diff --git a/vfe/vfecontrol.cpp b/vfe/vfecontrol.cpp index 91531aeae..3ce97a46f 100644 --- a/vfe/vfecontrol.cpp +++ b/vfe/vfecontrol.cpp @@ -37,6 +37,8 @@ #include +#include + #include "vfe.h" /***************************************************************************************/ @@ -49,6 +51,7 @@ namespace pov_frontend extern struct ProcessOptions::INI_Parser_Table RenderOptions_INI_Table[]; extern struct ProcessRenderOptions::Output_FileType_Table FileTypeTable[]; } +// end of namespace pov_frontend static struct pov_frontend::ProcessOptions::INI_Parser_Table *GetPT(const char *OptionName) { @@ -132,7 +135,7 @@ int vfeSession::CancelRender() return (m_LastError = vfeNoError); } -bool vfeSession::StopRender(const string& reason) +bool vfeSession::StopRender(const std::string& reason) { if (m_Frontend->GetState() <= kReady) return true; @@ -233,7 +236,7 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) m_InputFilename = opts.m_SourceFile; // most likely povray.ini will be the first INI file processed here (as it's included by default) - for (vector::iterator i = opts.m_IniFiles.begin(); i != opts.m_IniFiles.end(); i++) + for (std::vector::iterator i = opts.m_IniFiles.begin(); i != opts.m_IniFiles.end(); i++) { // we call TestAccessAllowed() here, even though ParseFile() will do it also, since if // access is denied, the reason will not be obvious (ParseFile() just returns kCannotOpenFileErr). @@ -260,7 +263,7 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) } // any source file set on the command-line overrides a source file set another way - for (vector::iterator i = opts.m_Commands.begin(); i != opts.m_Commands.end(); i++) + for (std::vector::iterator i = opts.m_Commands.begin(); i != opts.m_Commands.end(); i++) { if ((err = options.ParseString (i->c_str(), &obj)) != kNoErr) return (m_LastError = vfeFailedToParseCommand) ; @@ -311,7 +314,7 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) if (opts.m_LibraryPaths.empty() == false) { - for (vector::const_iterator i = opts.m_LibraryPaths.begin(); i != opts.m_LibraryPaths.end(); i++) + for (std::vector::const_iterator i = opts.m_LibraryPaths.begin(); i != opts.m_LibraryPaths.end(); i++) { Path path(*i); @@ -323,7 +326,7 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) if (libpaths.empty() == false) { POVMS_List pathlist; - for (list::iterator i = libpaths.begin(); i != libpaths.end(); i++) + for (std::list::iterator i = libpaths.begin(); i != libpaths.end(); i++) { POVMS_Attribute attr((*i)().c_str()); pathlist.Append(attr); @@ -532,3 +535,4 @@ int vfeSession::StartRender() } } +// end of namespace vfe diff --git a/vfe/vfedisplay.cpp b/vfe/vfedisplay.cpp index fdf59bc4d..4bdb74c24 100644 --- a/vfe/vfedisplay.cpp +++ b/vfe/vfedisplay.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -35,7 +35,6 @@ /// //****************************************************************************** -#include "backend/frame.h" #include "vfe.h" // this must be the last file included @@ -106,3 +105,4 @@ void vfeDisplay::Clear() } } +// end of namespace vfe diff --git a/vfe/vfepovms.cpp b/vfe/vfepovms.cpp index 18af608cc..00061106a 100644 --- a/vfe/vfepovms.cpp +++ b/vfe/vfepovms.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -57,12 +57,12 @@ class SysQNode void *Receive (int *pLen, bool Blocking) ; private: - typedef struct _DataNode + struct DataNode final { unsigned int Len; void *Data; - _DataNode *Next; - } DataNode ; + DataNode *Next; + }; unsigned int m_Sanity ; unsigned int m_Count ; @@ -253,3 +253,4 @@ POVMS_Sys_Thread_Type POVMS_GetCurrentThread (void) } } +// end of namespace vfe diff --git a/vfe/vfepovms.h b/vfe/vfepovms.h index f4d96f3a4..e46124863 100644 --- a/vfe/vfepovms.h +++ b/vfe/vfepovms.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -38,22 +38,26 @@ #ifndef POVRAY_VFE_VFEPOVMS_H #define POVRAY_VFE_VFEPOVMS_H +#include "base/stringtypes.h" +#include "povms/povmscpp.h" + namespace vfe { bool POVMS_Init (void); void POVMS_Shutdown (void); } +// end of namespace vfe //////////////////////////////////////////////////////////////////////////////////////// // templates to turn a type into a POVMS typeid. note not all POVMS types are supported. //////////////////////////////////////////////////////////////////////////////////////// -template struct GetPOVMSTypeID { enum { type_id = 0 } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_Bool } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_Int } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_Long } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_Float } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_CString } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_UCS2String } ; } ; +template struct GetPOVMSTypeID final { enum { type_id = 0 } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_Bool } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_Int } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_Long } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_Float } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_CString } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_UCS2String } ; } ; #endif // POVRAY_VFE_VFEPOVMS_H diff --git a/vfe/vfeprecomp.h b/vfe/vfeprecomp.h index 1c30d6001..6aa72d4eb 100644 --- a/vfe/vfeprecomp.h +++ b/vfe/vfeprecomp.h @@ -1,61 +1,79 @@ -//****************************************************************************** -/// -/// @file vfe/vfeprecomp.h -/// -/// Precompiled header for the user interface portions of POV-Ray. -/// -/// @copyright -/// @parblock -/// -/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. -/// -/// POV-Ray is free software: you can redistribute it and/or modify -/// it under the terms of the GNU Affero General Public License as -/// published by the Free Software Foundation, either version 3 of the -/// License, or (at your option) any later version. -/// -/// POV-Ray 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 Affero General Public License for more details. -/// -/// You should have received a copy of the GNU Affero General Public License -/// along with this program. If not, see . -/// -/// ---------------------------------------------------------------------------- -/// -/// POV-Ray is based on the popular DKB raytracer version 2.12. -/// DKBTrace was originally written by David K. Buck. -/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. -/// -/// @endparblock -/// -//****************************************************************************** - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +//****************************************************************************** +/// +/// @file vfe/vfeprecomp.h +/// +/// Precompiled header for the user interface portions of POV-Ray. +/// +/// @copyright +/// @parblock +/// +/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// +/// POV-Ray is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License, or (at your option) any later version. +/// +/// POV-Ray 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 Affero General Public License for more details. +/// +/// You should have received a copy of the GNU Affero General Public License +/// along with this program. If not, see . +/// +/// ---------------------------------------------------------------------------- +/// +/// POV-Ray is based on the popular DKB raytracer version 2.12. +/// DKBTrace was originally written by David K. Buck. +/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. +/// +/// @endparblock +/// +//****************************************************************************** + +/// @file +/// @note +/// @parblock +/// This header file is _not_ explicitly included in any source file (except @ref vfe/vfeprecomp.cpp +/// which is designed to allow for precompiling this header in the first place). To use +/// precompiled headers, you will therefore have to make your build environment automatically +/// inject this header at the start of every source file. +/// +/// The rationale behind this is to keep the set of headers included in each source file at an +/// absolute minimum when precompiled headers are _not_ used. +/// @endparblock + +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED + +// C++ variants of C standard header files +#include +#include +#include +#include +#include +#include +#include +#include + +// C++ standard header files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Boost header files +#include +#include +#include +#if POV_MULTITHREADED +#include +#endif \ No newline at end of file diff --git a/vfe/vfesession.cpp b/vfe/vfesession.cpp index 9d8f4a638..e857812dd 100644 --- a/vfe/vfesession.cpp +++ b/vfe/vfesession.cpp @@ -51,10 +51,15 @@ namespace pov static volatile POVMSAddress RenderThreadAddr = POVMSInvalidAddress ; static volatile POVMSAddress GUIThreadAddr = POVMSInvalidAddress ; } +// end of namespace pov namespace vfe { +using std::min; +using std::max; +using std::string; + bool vfeSession::m_Initialized = false; vfeSession *vfeSession::m_CurrentSessionTemporaryHack = nullptr; @@ -373,7 +378,7 @@ bool vfeSession::GetNextCombinedMessage (MessageType &Type, string& Message) // from the aforementioned queues; whichever is the earliest. Returns false // if there is no message to fetch, otherwise will set the message type, // filename, line, and column parameters supplied. If the message retrieved -// did not contain this information, the relevent entry is either set to 0 +// did not contain this information, the relevant entry is either set to 0 // (line and column) or the empty string (filename). The filename parameter // is a UCS2String. bool vfeSession::GetNextNonStatusMessage (MessageType &Type, string& Message, UCS2String& File, int& Line, int& Col) @@ -419,7 +424,7 @@ bool vfeSession::GetNextNonStatusMessage (MessageType &Type, string& Message, UC // from the aforementioned queues; whichever is the earliest. Returns false // if there is no message to fetch, otherwise will set the message type, // filename, line, and column parameters supplied. If the message retrieved -// did not contain this information, the relevent entry is either set to 0 +// did not contain this information, the relevant entry is either set to 0 // (line and column) or the empty string (filename). The filename parameter // is a std::string. bool vfeSession::GetNextNonStatusMessage (MessageType &Type, string& Message, string& File, int& Line, int& Col) @@ -544,10 +549,10 @@ const char *vfeSession::GetBackendStateName (void) const // Returns a copy of the shared pointer containing the current instance // of a pov_frontend::Display-derived render preview instance, which may // be `nullptr`. -shared_ptr vfeSession::GetDisplay() const +std::shared_ptr vfeSession::GetDisplay() const { if (m_Frontend == nullptr) - return (shared_ptr()); + return (std::shared_ptr()); return m_Frontend->GetDisplay(); } @@ -585,7 +590,7 @@ void vfeSession::WorkerThread() m_BackendThread = povray_init (boost::bind(&vfeSession::BackendThreadNotify, this), const_cast(&pov::RenderThreadAddr)) ; POVMS_Output_Context = pov::POVMS_GUI_Context ; - m_Console = shared_ptr (new vfeConsole(this, m_ConsoleWidth)) ; + m_Console = std::shared_ptr (new vfeConsole(this, m_ConsoleWidth)) ; POVMS_Object obj ; m_Frontend = new VirtualFrontEnd (*this, POVMS_Output_Context, (POVMSAddress) pov::RenderThreadAddr, obj, nullptr, m_Console); @@ -1101,3 +1106,4 @@ int vfeSession::Initialize(vfeDestInfo *Dest, vfeAuthInfo *Auth) } } +// end of namespace vfe diff --git a/vfe/vfesession.h b/vfe/vfesession.h index 023c33f9a..67edc574d 100644 --- a/vfe/vfesession.h +++ b/vfe/vfesession.h @@ -39,17 +39,22 @@ #ifndef POVRAY_VFE_VFESESSION_H #define POVRAY_VFE_VFESESSION_H +#include #include +#include #include #include +#include "base/stringutilities.h" + #include "frontend/simplefrontend.h" namespace pov_frontend { class Display; } +// end of namespace pov_frontend namespace vfe { @@ -71,7 +76,7 @@ namespace vfe IOPath(const Path& path, bool recursive) : m_Path(path), m_Recursive(recursive) {} // construct an IOPath given a std::string path and a recursion flag. - IOPath(const string& path, bool recursive) : m_Path(Path(SysToUCS2String(path))), m_Recursive(recursive) {} + IOPath(const std::string& path, bool recursive) : m_Path(Path(SysToUCS2String(path))), m_Recursive(recursive) {} // construct an IOPath given a UCS2String Path and a recursion flag. IOPath(const UCS2String& path, bool recursive) : m_Path(path), m_Recursive(recursive) {} @@ -90,9 +95,9 @@ namespace vfe } ; // convenience typedefs. - typedef vector StringVector; - typedef vector UCS2StringVector; - typedef vector IOPathVector; + typedef std::vector StringVector; + typedef std::vector UCS2StringVector; + typedef std::vector IOPathVector; class vfeDisplay; class VirtualFrontEnd; @@ -150,7 +155,7 @@ namespace vfe void ClearLibraryPaths() { m_LibraryPaths.clear(); } // Add a library path given a std::string. - void AddLibraryPath(const string& Path) { m_LibraryPaths.push_back(SysToUCS2String(Path)); } + void AddLibraryPath(const std::string& Path) { m_LibraryPaths.push_back(SysToUCS2String(Path)); } // Add a library path given a UCS2String. void AddLibraryPath(const UCS2String& Path) { m_LibraryPaths.push_back(Path); } @@ -171,7 +176,7 @@ namespace vfe // Set the source file to be parsed (must be an SDL file, INI not // permitted). The file is specified as a std::string full or relative // path, with optional extension. - void SetSourceFile(const string& File) { m_SourceFile = SysToUCS2String(File); } + void SetSourceFile(const std::string& File) { m_SourceFile = SysToUCS2String(File); } // Returns a const reference to the currently set source file (may be // an empty string). Return type is a const reference to a UCS2String. @@ -183,7 +188,7 @@ namespace vfe // Adds the supplied std::string to the list of INI files to be read // prior to the start of the render. The files are processed in the // order in which they are added to this list. - void AddINI(const string& File) { m_IniFiles.push_back(SysToUCS2String(File)); } + void AddINI(const std::string& File) { m_IniFiles.push_back(SysToUCS2String(File)); } // Adds the supplied UCS2String to the list of INI files to be read // prior to the start of the render. The files are processed in the @@ -201,7 +206,7 @@ namespace vfe // Sets the number of threads to be used for rendering (and potentially // for bounding and similar tasks, if this is supported in the future). // Clipped to the range 1..512. - void SetThreadCount(int Count) { m_ThreadCount = max(1, min(Count, 512)); } + void SetThreadCount(int Count) { m_ThreadCount = std::max(1, std::min(Count, 512)); } // Gets the number of threads currently set to be used for renders. // Defaults to 2. @@ -215,14 +220,14 @@ namespace vfe // order in which they appear in this list. A 'command' in this context // is basically anything that could normally appear on the command-line // of a POV-Ray console compile. - void AddCommand(const string& Command) { m_Commands.push_back(Command); } + void AddCommand(const std::string& Command) { m_Commands.push_back(Command); } - // Returns a const reference to a vector containing the + // Returns a const reference to a std::vector containing the // current list of commands as added by AddCommand(), in order first // to last. const StringVector& GetCommands() const { return m_Commands; } - // Returns a copy of the vector which holds the current + // Returns a copy of the std::vector which holds the current // list of commands as added by AddCommand(), in order first to last. StringVector GetCommands() { return m_Commands; } @@ -383,13 +388,13 @@ namespace vfe public: MessageBase(const vfeSession& session) : m_Id(session.GetID()), m_TimeStamp (session.GetTimestamp()), m_Type(mUnclassified) {} - MessageBase(const vfeSession& session, MessageType type, string msg = "") : + MessageBase(const vfeSession& session, MessageType type, std::string msg = "") : m_Id(session.GetID()), m_TimeStamp (session.GetTimestamp()), m_Type(type), m_Message(msg) {} virtual ~MessageBase() {} POV_LONG m_TimeStamp; MessageType m_Type; - string m_Message; + std::string m_Message; int m_Id; } ; @@ -403,9 +408,9 @@ namespace vfe public: GenericMessage(const vfeSession& session) : MessageBase(session), m_Line(0), m_Col(0) {} - GenericMessage(const vfeSession& session, MessageType type, string msg, const UCS2String file = UCS2String(), int line = 0, int col = 0) : + GenericMessage(const vfeSession& session, MessageType type, std::string msg, const UCS2String file = UCS2String(), int line = 0, int col = 0) : MessageBase (session, type, msg), m_Filename(file), m_Line(line), m_Col(col) {} - virtual ~GenericMessage() {} + virtual ~GenericMessage() override {} int m_Line; int m_Col; @@ -429,11 +434,11 @@ namespace vfe public: StatusMessage(const vfeSession& session) : MessageBase(session), m_Delay(0), m_Frame(0), m_TotalFrames(0), m_FrameId(0) {} - StatusMessage(const vfeSession& session, string msg, int m_Delay) : + StatusMessage(const vfeSession& session, std::string msg, int m_Delay) : MessageBase(session, mGenericStatus, msg), m_Delay(m_Delay), m_Frame(0), m_TotalFrames(0), m_FrameId(0) {} StatusMessage(const vfeSession& session, const UCS2String& file, int frame, int totalframes, int frameId) : MessageBase(session, mAnimationStatus), m_Delay(0), m_Filename(file), m_Frame(frame), m_TotalFrames(totalframes), m_FrameId(frameId) {} - virtual ~StatusMessage() {} + virtual ~StatusMessage() override {} int m_Delay; int m_Frame; @@ -528,7 +533,7 @@ namespace vfe // Returns a copy of the shared pointer containing the current instance // of a pov_frontend::Display-derived render preview instance, which may // be `nullptr`. - virtual shared_ptr GetDisplay() const; + virtual std::shared_ptr GetDisplay() const; // If a VFE implementation has provided a display creator functor via // vfeSession::SetDisplayCreator(), this method will call it with the @@ -912,7 +917,7 @@ namespace vfe // any additional meta-information the message may have had, such as the // line number of an error. (Note that this does not mean the line number // cannot be in the message string; it may very well be). - virtual bool GetNextCombinedMessage (MessageType &Type, string& Message); + virtual bool GetNextCombinedMessage (MessageType &Type, std::string& Message); // Gets the next non-status message (meaning generic or console messages) // from the aforementioned queues; whichever is the earliest. Returns false @@ -921,7 +926,7 @@ namespace vfe // did not contain this information, the relevent entry is either set to 0 // (line and column) or the empty string (filename). The filename parameter // is a UCS2String. - virtual bool GetNextNonStatusMessage (MessageType &Type, string& Message, UCS2String& File, int& Line, int& Col); + virtual bool GetNextNonStatusMessage (MessageType &Type, std::string& Message, UCS2String& File, int& Line, int& Col); // Gets the next non-status message (meaning generic or console messages) // from the aforementioned queues; whichever is the earliest. Returns false @@ -930,14 +935,14 @@ namespace vfe // did not contain this information, the relevent entry is either set to 0 // (line and column) or the empty string (filename). The filename parameter // is a std::string. - virtual bool GetNextNonStatusMessage (MessageType &Type, string& Message, string& File, int& Line, int& Col); + virtual bool GetNextNonStatusMessage (MessageType &Type, std::string& Message, std::string& File, int& Line, int& Col); // Gets the next non-status message (meaning generic or console messages) // from the aforementioned queues; whichever is the earliest. Returns false // if there is no message to fetch, otherwise will set the message type // and text content parameters supplied. Any additional meta-information // that may have been contained in the message is discarded. - virtual bool GetNextNonStatusMessage (MessageType &Type, string& Message); + virtual bool GetNextNonStatusMessage (MessageType &Type, std::string& Message); // Returns false if there are no messages in the status message // queue, otherwise removes the oldest status message from the @@ -964,7 +969,7 @@ namespace vfe // event notification, as appropriate. Upon receiving either of the above // events therefore you may like to simply call this method and place the // returned value wherever suitable, overwriting the previous value.2 - virtual string GetStatusLineMessage() { return m_StatusLineMessage; } + virtual std::string GetStatusLineMessage() { return m_StatusLineMessage; } // Sets the maximum number of status messages that will be stored in the // status queue. If this limit is reached, the oldest message will be @@ -999,7 +1004,7 @@ namespace vfe // Allows you to manually set the console wrap width. // The supplied value is clipped to the range 80-999. - virtual void SetConsoleWidth(int width) { m_ConsoleWidth = max(min(999,width),80); } + virtual void SetConsoleWidth(int width) { m_ConsoleWidth = std::max(std::min(999,width),80); } // Return the current console wrap width. virtual int GetConsoleWidth(void) { return m_ConsoleWidth; } @@ -1020,7 +1025,7 @@ namespace vfe // Adds the supplied path to the list of allowed read paths, along with // the recursive flag (meaning paths under that path are also allowed). // The supplied path is a std::string. - virtual void AddReadPath(const string& path, bool recursive = true) { m_ReadPaths.push_back(IOPath(path, recursive)); } + virtual void AddReadPath(const std::string& path, bool recursive = true) { m_ReadPaths.push_back(IOPath(path, recursive)); } // Adds the supplied path to the list of allowed read paths. // The supplied path is a pre-constructed IOPath instance. @@ -1039,7 +1044,7 @@ namespace vfe // Adds the supplied path to the list of allowed write paths, along with // the recursive flag (meaning paths under that path are also allowed). // The supplied path is a std::string. - virtual void AddWritePath(const string& path, bool recursive = true) { m_WritePaths.push_back(IOPath(path, recursive)); } + virtual void AddWritePath(const std::string& path, bool recursive = true) { m_WritePaths.push_back(IOPath(path, recursive)); } // Adds the supplied path to the list of allowed write paths. // The supplied path is a pre-constructed IOPath instance. @@ -1062,7 +1067,7 @@ namespace vfe // Adds the supplied path to the list of excluded paths, along with the // recursion flag. The supplied path is a std::string. - virtual void AddExcludedPath(const string& path, bool recursive = true) { m_ExcludedPaths.push_back(IOPath(path, recursive)); } + virtual void AddExcludedPath(const std::string& path, bool recursive = true) { m_ExcludedPaths.push_back(IOPath(path, recursive)); } // Adds the supplied path to the list of excluded paths, along with the // recursion flag. The supplied path is a pre-constructed IOPath instance. @@ -1102,12 +1107,12 @@ namespace vfe // state changs to rendering. virtual POV_LONG GetElapsedTime() { return GetTimestamp() - m_StartTime; } - virtual void AppendErrorMessage (const string& Msg); - virtual void AppendWarningMessage (const string& Msg); - virtual void AppendStatusMessage (const string& Msg, int RecommendedPause = 0); + virtual void AppendErrorMessage (const std::string& Msg); + virtual void AppendWarningMessage (const std::string& Msg); + virtual void AppendStatusMessage (const std::string& Msg, int RecommendedPause = 0); virtual void AppendStatusMessage (const boost::format& fmt, int RecommendedPause = 0); - virtual void AppendWarningAndStatusMessage (const string& Msg, int RecommendedPause = 0) { AppendWarningMessage(Msg); AppendStatusMessage(Msg, RecommendedPause); } - virtual void AppendErrorAndStatusMessage (const string& Msg, int RecommendedPause = 0) { AppendErrorMessage(Msg); AppendStatusMessage(Msg, RecommendedPause); } + virtual void AppendWarningAndStatusMessage (const std::string& Msg, int RecommendedPause = 0) { AppendWarningMessage(Msg); AppendStatusMessage(Msg, RecommendedPause); } + virtual void AppendErrorAndStatusMessage (const std::string& Msg, int RecommendedPause = 0) { AppendErrorMessage(Msg); AppendStatusMessage(Msg, RecommendedPause); } // returns true if a render cancel was requested at some point since the render started. virtual bool GetCancelRequested() { return m_RenderCancelRequested | m_RenderCancelled ; } @@ -1127,8 +1132,8 @@ namespace vfe virtual void AppendStreamMessage (MessageType type, const char *message, bool chompLF = false); virtual void AppendStreamMessage (MessageType type, const boost::format& fmt, bool chompLF = false); - virtual void AppendErrorMessage (const string& Msg, const UCS2String& File, int Line = 0, int Col = 0); - virtual void AppendWarningMessage (const string& Msg, const UCS2String& File, int Line = 0, int Col = 0); + virtual void AppendErrorMessage (const std::string& Msg, const UCS2String& File, int Line = 0, int Col = 0); + virtual void AppendWarningMessage (const std::string& Msg, const UCS2String& File, int Line = 0, int Col = 0); virtual void AppendAnimationStatus (int FrameId, int SubsetFrame, int SubsetTotal, const UCS2String& Filename); virtual void SetUsingAlpha() { m_UsingAlpha = true ; } @@ -1143,7 +1148,7 @@ namespace vfe virtual bool ProcessFrontend (void); virtual bool ProcessCancelRender(void); - virtual bool StopRender(const string& reason); + virtual bool StopRender(const std::string& reason); // This method allows your platform code to perform platform-specific actions // when a render stops (whether it succeeds or fails). A good example would @@ -1205,11 +1210,11 @@ namespace vfe // NB this method is pure virtual. // // NOTE: The code to call this method isn't implemented in vfe yet. - virtual int RequestNewOutputPath(int CallCount, const string& Reason, const UCS2String& OldPath, UCS2String& NewPath) = 0; + virtual int RequestNewOutputPath(int CallCount, const std::string& Reason, const UCS2String& OldPath, UCS2String& NewPath) = 0; // Create an instance of the frontend ShelloutProcessing class. this handles creating and // managing render shellout commands, and typically will need platform-specific implementation. - virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height) { return new ShelloutProcessing(opts, scene, width, height); } + virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height) { return new ShelloutProcessing(opts, scene, width, height); } struct vfeSessionWorker { @@ -1254,7 +1259,7 @@ namespace vfe static bool m_Initialized; static vfeSession *m_CurrentSessionTemporaryHack; - shared_ptr m_Console; + std::shared_ptr m_Console; virtual vfeDisplay *DefaultDisplayCreator (unsigned int width, unsigned int height, vfeSession *session, bool visible); DisplayCreator m_DisplayCreator; @@ -1265,7 +1270,7 @@ namespace vfe GenericQueue m_MessageQueue; StatusQueue m_StatusQueue; ConsoleQueue m_ConsoleQueue; - string m_StatusLineMessage; + std::string m_StatusLineMessage; UCS2String m_OutputFilename; UCS2String m_InputFilename; IOPathVector m_ReadPaths; @@ -1293,5 +1298,6 @@ namespace vfe volatile int m_RequestResult; } ; } +// end of namespace vfe #endif // POVRAY_VFE_VFESESSION_H diff --git a/vfe/win/console/winconsole.cpp b/vfe/win/console/winconsole.cpp index 59c4b8269..5546828bf 100644 --- a/vfe/win/console/winconsole.cpp +++ b/vfe/win/console/winconsole.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -56,6 +56,7 @@ namespace pov_frontend bool MinimizeShellouts(void) { return false; } // TODO bool ShelloutsPermitted(void) { return false; } // TODO } +// end of namespace pov_frontend void PrintStatus (vfeSession *session) diff --git a/vfe/win/syspovimage.h b/vfe/win/syspovimage.h index 7f2d568ed..a81cb1794 100644 --- a/vfe/win/syspovimage.h +++ b/vfe/win/syspovimage.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,8 @@ #ifndef POVRAY_VFE_WIN_SYSPOVIMAGE_H #define POVRAY_VFE_WIN_SYSPOVIMAGE_H +#include "base/image/image_fwd.h" + #ifdef POV_VIDCAP_IMPL namespace pov { @@ -45,7 +47,7 @@ public: VideoCaptureImpl(); ~VideoCaptureImpl(); - Image *Init(const char *params, Image::ReadOptions& options, bool doubleBuffer); + pov_base::Image *Init(const char *params, pov_base::ImageReadOptions& options, bool doubleBuffer); void UpdateImage(); bool WaitFrame(int count, unsigned int timeout); @@ -54,6 +56,7 @@ int m_WaitFrames; }; } + // end of namespace pov #endif // POV_VIDCAP_IMPL #endif // POVRAY_VFE_WIN_SYSPOVIMAGE_H diff --git a/vfe/win/vfeplatform.cpp b/vfe/win/vfeplatform.cpp index d81569554..38ba09b2f 100644 --- a/vfe/win/vfeplatform.cpp +++ b/vfe/win/vfeplatform.cpp @@ -35,9 +35,14 @@ /// //****************************************************************************** +#include + +#include #include #include "vfe.h" +#include "base/filesystem.h" +#include "base/stringtypes.h" #include @@ -46,6 +51,7 @@ namespace pov_frontend bool MinimizeShellouts(void); bool ShelloutsPermitted(void); } +// end of namespace pov_frontend namespace vfePlatform { @@ -72,16 +78,9 @@ namespace vfePlatform // if we fail to creat our temp dir, just use the default one if ((CreateDirectory(str, nullptr) == 0) && (GetLastError() != ERROR_ALREADY_EXISTS)) GetTempPath (sizeof (str), str); - m_TempPath = Path(str); m_TempPathString = str; } - vfeWinSession::~vfeWinSession() - { - for (vector::const_iterator it = m_TempFilenames.begin(); it != m_TempFilenames.end(); it++) - DeleteFile(it->c_str()); - } - void vfeWinSession::Clear(bool Notify) { m_ReadFiles.clear(); @@ -132,7 +131,7 @@ namespace vfePlatform // error will occur again (e.g. invalid output path or something), then // you may want to call the render cancel API so the user isn't bombarded // with an error message for each frame of the render. - int vfeWinSession::RequestNewOutputPath(int CallCount, const string& Reason, const UCS2String& OldPath, UCS2String& NewPath) + int vfeWinSession::RequestNewOutputPath(int CallCount, const std::string& Reason, const UCS2String& OldPath, UCS2String& NewPath) { // TODO return 0; @@ -145,8 +144,10 @@ namespace vfePlatform ///////////////////////////////////////////////////////////////////////// // return an absolute path including trailing path separator. // *nix platforms might want to just return "/tmp/" here. + // (NB This implementation actually returns UTF-16.) UCS2String vfeWinSession::GetTemporaryPath(void) const { +// return m_TempPathString; return SysToUCS2String(m_TempPathString); } @@ -156,12 +157,9 @@ namespace vfePlatform // name to one that it can use. UCS2String vfeWinSession::CreateTemporaryFile(void) const { - char str [MAX_PATH] = "" ; - - GetTempFileName (m_TempPathString.c_str(), "pv", 0, str) ; - remove (str) ; - m_TempFilenames.push_back(str); - return SysToUCS2String(str); + pov_base::Filesystem::TemporaryFilePtr tempFile(new pov_base::Filesystem::TemporaryFile); + m_TempFiles.push_back(tempFile); + return tempFile->GetFileName(); } ///////////////////////////////////////////////////////////////////////// @@ -170,7 +168,7 @@ namespace vfePlatform // example doesn't do that but it's not a bad idea to add. void vfeWinSession::DeleteTemporaryFile(const UCS2String& filename) const { - remove (UCS2toSysString (filename).c_str()); + pov_base::Filesystem::DeleteFile(filename); } ////////////////////////////////////////////////////////////// @@ -274,8 +272,8 @@ namespace vfePlatform if (StrCompareIC(path.GetVolume(), file.GetVolume()) == false) return (false); - vector pc = path.GetAllFolders(); - vector fc = file.GetAllFolders(); + std::vector pc = path.GetAllFolders(); + std::vector fc = file.GetAllFolders(); if (fc.size() < pc.size()) return (false) ; for (int i = 0 ; i < pc.size(); i++) @@ -307,7 +305,7 @@ namespace vfePlatform if (isWrite == false && GetReadPaths().empty() == true) returnOK = true; - int n = GetFullPathName (UCS2toSysString(file()).c_str(), sizeof (buf), buf, &s); + int n = GetFullPathName (UCS2toSysString(file()).c_str(), _MAX_PATH, buf, &s); if ((n == 0) || (n > sizeof(buf)) || (s == nullptr) || (s == buf)) { if (returnOK == true) @@ -318,8 +316,8 @@ namespace vfePlatform } // GetLongPathName is available on win95 due to the inclusion of newapis.h - n = GetLongPathName (buf, longbuf, sizeof (longbuf)) ; - if ((n > 0) && (n < sizeof(longbuf))) + n = GetLongPathName(buf, longbuf, _MAX_PATH) ; + if ((n > 0) && (n < _MAX_PATH)) { // we store the filename before doing anything else, since this may be used elsewhere // note that we convert it to lower case first @@ -342,8 +340,8 @@ namespace vfePlatform if (_stricmp(m_TempPathString.c_str(), buf) == 0) return (true); - n = GetLongPathName (buf, buf, sizeof (buf)) ; - if ((n == 0) || (n > sizeof(buf))) + n = GetLongPathName(buf, buf, _MAX_PATH); + if ((n == 0) || (n > _MAX_PATH)) { if (GetLastError() != ERROR_PATH_NOT_FOUND) { @@ -386,15 +384,15 @@ namespace vfePlatform // is not yet known, use the current working directory. if (m_InputFilename.empty() == true) { - if (_getcwd (buf, sizeof (buf) - 2) == nullptr) + if (_getcwd(buf, _MAX_PATH - 2) == nullptr) { // TODO: issue appropriate error message return (false) ; } } else - n = GetFullPathName (UCS2toSysString(m_InputFilename).c_str(), sizeof (buf), buf, &s); - if ((n == 0) || (n > sizeof(buf)) || (s == nullptr) || (s == buf)) + n = GetFullPathName (UCS2toSysString(m_InputFilename).c_str(), _MAX_PATH, buf, &s); + if ((n == 0) || (n > _MAX_PATH) || (s == nullptr) || (s == buf)) { // TODO: issue appropriate error message return (false) ; @@ -404,11 +402,11 @@ namespace vfePlatform // as the source filename may be incomplete (e.g. 'c:\temp\test' for c:\temp\test.pov). _splitpath(buf, drive, dir, nullptr, nullptr); sprintf(buf, "%s%s", drive, dir); - n = GetLongPathName (buf, buf, sizeof (buf)) ; - if ((n == 0) || (n > sizeof(buf))) + n = GetLongPathName(buf, buf, _MAX_PATH) ; + if ((n == 0) || (n > _MAX_PATH)) { if (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_FILE_NOT_FOUND) - throw POV_EXCEPTION(kCannotOpenFileErr, string ("Input folder '") + buf + "' not found; cannot determine I/O permission for write."); + throw POV_EXCEPTION(kCannotOpenFileErr, std::string("Input folder '") + buf + "' not found; cannot determine I/O permission for write."); // TODO: issue appropriate error message return (false) ; @@ -424,7 +422,7 @@ namespace vfePlatform ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// - WinShelloutProcessing::WinShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height): ShelloutProcessing(opts, scene, width, height) + WinShelloutProcessing::WinShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height): ShelloutProcessing(opts, scene, width, height) { m_ProcessRunning = false; m_ProcessId = m_LastError = m_ExitCode = 0; @@ -450,7 +448,7 @@ namespace vfePlatform } // in the windows version of ExtractCommand, we don't treat backslashes in the command itself specially - bool WinShelloutProcessing::ExtractCommand(const string& src, string& command, string& parameters) const + bool WinShelloutProcessing::ExtractCommand(const std::string& src, std::string& command, std::string& parameters) const { bool inSQ = false; bool inDQ = false; @@ -459,8 +457,8 @@ namespace vfePlatform command.clear(); parameters.clear(); - string str = boost::trim_copy(src); - string tmp = boost::to_lower_copy(str); + std::string str = boost::trim_copy(src); + std::string tmp = boost::to_lower_copy(str); for (s = str.c_str(); *s != '\0'; s++) { @@ -489,11 +487,11 @@ namespace vfePlatform } } - parameters = boost::trim_copy(string(s)); + parameters = boost::trim_copy(std::string(s)); return true; } - bool WinShelloutProcessing::ExecuteCommand(const string& cmd, const string& params) + bool WinShelloutProcessing::ExecuteCommand(const std::string& cmd, const std::string& params) { STARTUPINFO startupInfo; PROCESS_INFORMATION procInfo; @@ -513,7 +511,7 @@ namespace vfePlatform startupInfo.dwFlags = pov_frontend::MinimizeShellouts() ? STARTF_USESHOWWINDOW : 0; startupInfo.wShowWindow = SW_SHOWMINNOACTIVE; - shared_ptr buf(new char[params.size() + 1]); + std::shared_ptr buf(new char[params.size() + 1]); strcpy(buf.get(), params.c_str()); if ((m_ProcessRunning = CreateProcess(cmd.c_str(), buf.get(), nullptr, nullptr, false, 0, nullptr, nullptr, &startupInfo, &procInfo))) { @@ -561,7 +559,7 @@ namespace vfePlatform return m_ExitCode; } - int WinShelloutProcessing::CollectCommand(string& output) + int WinShelloutProcessing::CollectCommand(std::string& output) { if (m_ProcessRunning == false && m_LastError != 0) { @@ -582,9 +580,10 @@ namespace vfePlatform return CollectCommand(); } - bool WinShelloutProcessing::CommandPermitted(const string& command, const string& parameters) + bool WinShelloutProcessing::CommandPermitted(const std::string& command, const std::string& parameters) { // this may change during a render, so we check it in real time return pov_frontend::ShelloutsPermitted(); } } +// end of namespace vfePlatform diff --git a/vfe/win/vfeplatform.h b/vfe/win/vfeplatform.h index cbf76b89c..84df777fb 100644 --- a/vfe/win/vfeplatform.h +++ b/vfe/win/vfeplatform.h @@ -38,6 +38,11 @@ #ifndef POVRAY_VFE_WIN_VFEPLATFORM_H #define POVRAY_VFE_WIN_VFEPLATFORM_H +#include + +#include "base/stringtypes.h" +#include "base/filesystem_fwd.h" + #include "frontend/shelloutprocessing.h" #include "vfesession.h" @@ -45,27 +50,27 @@ namespace vfePlatform { using namespace vfe; - class WinShelloutProcessing: public pov_frontend::ShelloutProcessing + class WinShelloutProcessing final : public pov_frontend::ShelloutProcessing { public: - WinShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height); - virtual ~WinShelloutProcessing(); + WinShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height); + virtual ~WinShelloutProcessing() override; - virtual int ProcessID(void); - virtual bool ShelloutsSupported(void) { return true; } + virtual int ProcessID(void) override; + virtual bool ShelloutsSupported(void) override { return true; } protected: - virtual bool ExecuteCommand(const string& cmd, const string& params); - virtual bool KillCommand(int timeout, bool force = false); - virtual bool CommandRunning(void); - virtual int CollectCommand(string& output); - virtual int CollectCommand(void); - virtual bool CommandPermitted(const string& command, const string& parameters); - virtual bool ExtractCommand(const string& src, string& command, string& parameters) const; + virtual bool ExecuteCommand(const std::string& cmd, const std::string& params) override; + virtual bool KillCommand(int timeout, bool force = false) override; + virtual bool CommandRunning(void) override; + virtual int CollectCommand(std::string& output) override; + virtual int CollectCommand(void) override; + virtual bool CommandPermitted(const std::string& command, const std::string& parameters) override; + virtual bool ExtractCommand(const std::string& src, std::string& command, std::string& parameters) const override; bool m_ProcessRunning; - string m_Command; - string m_Params; + std::string m_Command; + std::string m_Params; void *m_ProcessHandle; void *m_ThreadHandle; unsigned long m_ExitCode; @@ -73,51 +78,51 @@ namespace vfePlatform unsigned long m_ProcessId; private: - WinShelloutProcessing(); + + WinShelloutProcessing() = delete; }; /////////////////////////////////////////////////////////////////////// // most of the methods in vfeWinSession are derived from vfeSession. // see vfeSession for documentation for those cases. - class vfeWinSession : public vfeSession + class vfeWinSession final : public vfeSession { public: - typedef std::set FilenameSet; + typedef std::set FilenameSet; vfeWinSession(int id = 0); - virtual ~vfeWinSession(); - virtual UCS2String GetTemporaryPath(void) const; - virtual UCS2String CreateTemporaryFile(void) const; - virtual void DeleteTemporaryFile(const UCS2String& filename) const; - virtual POV_LONG GetTimestamp(void) const ; - virtual void NotifyCriticalError(const char *message, const char *file, int line); - virtual int RequestNewOutputPath(int CallCount, const string& Reason, const UCS2String& OldPath, UCS2String& NewPath); - virtual bool TestAccessAllowed(const Path& file, bool isWrite) const; - virtual bool ImageOutputToStdoutSupported(void) const { return m_OptimizeForConsoleOutput; } - virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height) { return new WinShelloutProcessing(opts, scene, width, height); } + virtual UCS2String GetTemporaryPath(void) const override; + virtual UCS2String CreateTemporaryFile(void) const override; + virtual void DeleteTemporaryFile(const UCS2String& filename) const override; + virtual POV_LONG GetTimestamp(void) const override; + virtual void NotifyCriticalError(const char *message, const char *file, int line) override; + virtual int RequestNewOutputPath(int CallCount, const std::string& Reason, const UCS2String& OldPath, UCS2String& NewPath) override; + virtual bool TestAccessAllowed(const Path& file, bool isWrite) const override; + virtual bool ImageOutputToStdoutSupported(void) const override { return m_OptimizeForConsoleOutput; } + virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height) override { return new WinShelloutProcessing(opts, scene, width, height); } - virtual void Clear(bool Notify = true); + virtual void Clear(bool Notify = true) override; const FilenameSet& GetReadFiles(void) const { return m_ReadFiles; } const FilenameSet& GetWriteFiles(void) const { return m_WriteFiles; } protected: - virtual void WorkerThreadStartup(); - virtual void WorkerThreadShutdown(); + virtual void WorkerThreadStartup() override; + virtual void WorkerThreadShutdown() override; /////////////////////////////////////////////////////////////////////// // return true if the path component of file is equal to the path component // of path. will also return true if recursive is true and path is a parent // of file. does not support relative paths, and will convert UCS2 paths to // Latin-1 and perform case-insensitive comparisons. - virtual bool TestPath(const Path& path, const Path& file, bool recursive) const; + bool TestPath(const Path& path, const Path& file, bool recursive) const; /////////////////////////////////////////////////////////////////////// // perform case-insensitive UCS2 string comparison. does not take code- // page into account. - virtual bool StrCompareIC (const UCS2String& lhs, const UCS2String& rhs) const; + bool StrCompareIC (const UCS2String& lhs, const UCS2String& rhs) const; /////////////////////////////////////////////////////////////////////// // used to detect wall clock changes to prevent GetTimeStamp() @@ -129,9 +134,8 @@ namespace vfePlatform //////////////////////////////////////////////////////////////////// // used to store the location of the temp path. this is used by both // GetTemporaryPath() and TestAccessAllowed(). - Path m_TempPath; - string m_TempPathString; - mutable vector m_TempFilenames; + std::string m_TempPathString; + mutable std::vector m_TempFiles; mutable FilenameSet m_ReadFiles; mutable FilenameSet m_WriteFiles; } ; @@ -141,5 +145,6 @@ namespace vfePlatform // all other running threads in the process (and preferably in the OS). POVMS_Sys_Thread_Type GetThreadId(); } +// end of namespace vfePlatform #endif // POVRAY_VFE_WIN_VFEPLATFORM_H diff --git a/windows/povconfig/syspovconfig.h b/windows/povconfig/syspovconfig.h index 9c8e04971..fc8ac415a 100644 --- a/windows/povconfig/syspovconfig.h +++ b/windows/povconfig/syspovconfig.h @@ -13,7 +13,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -55,54 +55,13 @@ // failure to do so will lead to link errors. // #define _CONSOLE -// C++ variants of C standard headers -#include -#include -#include +// C++ variants of C standard header files +#include // TODO - Required for `_isnan()`, `_finite()`. +#include // TODO - required for `_MAX_PATH`, `std::memcpy()`[1], `std::malloc()`, `std::realloc()`, `std::free()`. +#include // TODO - Required for `std::memmove() `std::memcpy()`[1], `std::strdup()`. -// C++ standard headers -#include -#include -#include -#include -#include -#include - -// boost headers -#include - -#include -#include - -#ifndef STD_TYPES_DECLARED -#define STD_TYPES_DECLARED - -// the following types are used extensively throughout the POV source and hence are -// included and named here for reasons of clarity and convenience. - -// when we say 'string' we mean std::string -using std::string; - -// and vector is a std::vector -using std::vector; - -// yup, list too -using std::list; - -// runtime_error is the base of our Exception class, plus is referred -// to in a few other places. -using std::runtime_error; - -// we use the C++11 standard shared pointers -using std::shared_ptr; -using std::weak_ptr; -using std::dynamic_pointer_cast; -using std::static_pointer_cast; -using std::const_pointer_cast; - -using boost::intrusive_ptr; - -#endif // STD_POV_TYPES_DECLARED +// C++ standard header files +// (none at the moment) // the build command-line is expected to declare WIN32_LEAN_AND_MEAN, which will // prevent Window's objidl.h from being pulled in (which dupes IStream) @@ -186,6 +145,7 @@ namespace povwin #endif #ifndef _WIN64 + // TODO FIXME - The following will obviously only work on x86 machines. inline void DebugBreak() { _asm _emit 0cch } // rather than use the windows one inline POV_LONG RDTSC(){ _asm _emit 0Fh _asm _emit 31h } #define READ_PROFILE_TIMER RDTSC() @@ -194,27 +154,11 @@ namespace povwin #define READ_PROFILE_TIMER 0 #endif } +// end of namespace povwin #ifdef __INTEL_COMPILER #pragma warning(pop) #endif -// MS Windows provides large file support via the `_lseeki64` function, -// with file offsets having type `__int64`. -#define POV_LSEEK(handle,offset,whence) _lseeki64(handle,offset,whence) -#define POV_OFF_T __int64 - -namespace pov_base -{ - // declare these to avoid warnings in image.cpp, rather than turn off the deprecation warnings. - static inline int open(const char *name, int flags, int mode) { return _open(name, flags|_O_BINARY, mode); } - static inline int close(int handle) { return _close(handle); } - static inline int write(int handle, const void *data, int count) { return _write(handle, data, count); } - static inline int read(int handle, void *data, int count) { return _read(handle, data, count); } -} - -#define S_IRUSR _S_IREAD -#define S_IWUSR _S_IWRITE - #define ALTMAIN #define LITTLE_ENDIAN #define POV_PATH_SEPARATOR '\\' @@ -225,13 +169,10 @@ namespace pov_base #define POV_IS2 ".BMP" #define DEFAULT_DISPLAY_GAMMA_TYPE kPOVList_GammaType_SRGB #define DEFAULT_DISPLAY_GAMMA 2.2 -#define RENAME_FILE(orig,new) rename(orig,new) -#define POV_DELETE_FILE(name) _unlink(name) #define POV_NEW_LINE_STRING "\r\n" #define POV_SYS_IMAGE_EXTENSION ".bmp" #define POV_SYS_IMAGE_TYPE BMP #define POV_FILENAME_BUFFER_CHARS (_MAX_PATH-1) // (NB: _MAX_PATH includes terminating NUL character) -#define IFF_SWITCH_CAST (long) #define USE_OFFICIAL_BOOST 1 #define POV_MEMMOVE(dst,src,len) std::memmove((dst),(src),(len)) @@ -239,10 +180,10 @@ namespace pov_base #ifdef _CONSOLE -#define POV_MALLOC(size,msg) malloc (size) -#define POV_REALLOC(ptr,size,msg) realloc ((ptr), (size)) -#define POV_FREE(ptr) do { free (static_cast(ptr)); (ptr) = NULL; } while(false) -#define POV_STRDUP(str) strdup(str) +#define POV_MALLOC(size,msg) std::malloc (size) +#define POV_REALLOC(ptr,size,msg) std::realloc ((ptr), (size)) +#define POV_FREE(ptr) do { std::free (static_cast(ptr)); (ptr) = NULL; } while(false) +#define POV_STRDUP(str) std::strdup(str) #define NO_RTR 1 #define MEM_STATS 0 @@ -277,6 +218,7 @@ namespace pov { class VideoCaptureImpl; } +// end of namespace pov #endif // end of not _CONSOLE // see RLP comment in v3.6 windows config.h @@ -290,11 +232,6 @@ namespace pov #define OBJECT_DEBUG_HELPER #endif -// TODO REVIEW - Is this actually required for any Windows platform? -#ifndef MAX_PATH - #define MAX_PATH _MAX_PATH -#endif - #ifndef NO_RTR #define RTR_HACK #define RTR_SUPPORT diff --git a/windows/povconfig/syspovconfig_msvc.h b/windows/povconfig/syspovconfig_msvc.h index ab414b0bb..e7dc82676 100644 --- a/windows/povconfig/syspovconfig_msvc.h +++ b/windows/povconfig/syspovconfig_msvc.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -46,11 +46,10 @@ #endif // C++ variants of C standard header files -#include -#include +// (none at the moment) // Other library header files -#include +#include // TODO - Required for `_ReturnAddress()`. #pragma auto_inline(on) @@ -100,6 +99,7 @@ #define METADATA_COMPILER_STRING "msvc 8" #define NEED_INVHYP #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 #elif _MSC_VER >= 1400 && _MSC_VER < 1500 && defined (_WIN64) // MS Visual C++ 2005 (aka 8.0), compiling for 64 bit target #define POV_COMPILER_VER "msvc8" @@ -115,12 +115,14 @@ inline const unsigned long& min(const unsigned long& _X, const unsigned long& _Y) {return (_Y < _X ? _Y : _X); } #define NEED_INVHYP #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 #elif _MSC_VER >= 1500 && _MSC_VER < 1600 // MS Visual C++ 2008 (aka 9.0) #define POV_COMPILER_VER "msvc9" #define METADATA_COMPILER_STRING "msvc 9" #define NEED_INVHYP #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 #elif _MSC_VER >= 1600 && _MSC_VER < 1700 // MS Visual C++ 2010 (aka 10.0) #define POV_COMPILER_VER "msvc10" @@ -130,6 +132,7 @@ #pragma warning(disable : 4099) #define NEED_INVHYP #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 #elif _MSC_VER >= 1700 && _MSC_VER < 1800 // MS Visual C++ 2012 (aka 11.0) #define POV_COMPILER_VER "msvc11" @@ -138,6 +141,7 @@ // The following settings are just guesswork, and have never been tested: #define NEED_INVHYP #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 #elif _MSC_VER >= 1800 && _MSC_VER < 1900 // MS Visual C++ 2013 (aka 12.0) #define POV_COMPILER_VER "msvc12" @@ -145,12 +149,14 @@ #error "Please update syspovconfig_msvc.h to include this version of MSVC" // The following settings are just guesswork, and have never been tested: #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 // NB: The Microsoft Visual Studio developers seem to have skipped internal version number 13 entirely. #elif _MSC_VER >= 1900 && _MSC_VER < 2000 // MS Visual C++ 2015 (aka 14.0) #define POV_COMPILER_VER "msvc14" #define METADATA_COMPILER_STRING "msvc 14" #define POV_CPP11_SUPPORTED 1 + #define POV_CPP14_SUPPORTED 1 #ifndef DEBUG // Suppress erroneous warning about `string` having different alignment in base and parser. #pragma warning(disable : 4742) // 'var' has different alignment in 'file1' and 'file2': number and number @@ -204,7 +210,6 @@ #endif #endif -#define QSORT(a,b,c,d) std::qsort(reinterpret_cast(a), (size_t) b, (size_t) c, d) #define POV_LONG signed __int64 #define POV_ULONG unsigned __int64 #define FORCEINLINE __forceinline diff --git a/windows/povconfig/syspovconfigbase.h b/windows/povconfig/syspovconfigbase.h index c9b4152ee..b2f90dabe 100644 --- a/windows/povconfig/syspovconfigbase.h +++ b/windows/povconfig/syspovconfigbase.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -57,4 +57,10 @@ // Windows requires platform-specific parsing of path name strings. #define POV_USE_DEFAULT_PATH_PARSER 0 +// Windows requires a platform-specific function to delete a file. +#define POV_USE_DEFAULT_DELETEFILE 0 + +// Windows gets a platform-specific implementation of large file handling. +#define POV_USE_DEFAULT_LARGEFILE 0 + #endif // POVRAY_WINDOWS_SYSPOVCONFIGBASE_H diff --git a/windows/pvbitmap.cpp b/windows/pvbitmap.cpp index c215e0519..102280af1 100644 --- a/windows/pvbitmap.cpp +++ b/windows/pvbitmap.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -1831,3 +1831,4 @@ DWORD PASCAL MyWrite(int iFileHandle, VOID *lpBuffer, DWORD dwBytes) } } +// end of namespace povwin diff --git a/windows/pvbitmap.h b/windows/pvbitmap.h index d76fba550..1f576ca68 100644 --- a/windows/pvbitmap.h +++ b/windows/pvbitmap.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -95,3 +95,4 @@ enum { #define RECTHEIGHT(lpRect) ((lpRect)->bottom - (lpRect)->top) } +// end of namespace povwin diff --git a/windows/pvdemo.h b/windows/pvdemo.h index f420e1ac2..7e7b1aa39 100644 --- a/windows/pvdemo.h +++ b/windows/pvdemo.h @@ -12,7 +12,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -426,3 +426,4 @@ char *povdemo_ini [] = } ; } +// end of namespace povwin diff --git a/windows/pvdialog.cpp b/windows/pvdialog.cpp index 3b13d44d8..eed60ecdb 100644 --- a/windows/pvdialog.cpp +++ b/windows/pvdialog.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -979,3 +979,4 @@ void FeatureNotify (const char *labelStr, const char *titleStr, const char *text } } +// end of namespace povwin diff --git a/windows/pvdialog.h b/windows/pvdialog.h index b999bf3bd..52ffe3f70 100644 --- a/windows/pvdialog.h +++ b/windows/pvdialog.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -53,5 +53,6 @@ INT_PTR CALLBACK RenderAlternativeFileDialogProc (HWND hDlg, UINT message, WPARA void FeatureNotify (const char *labelStr, const char *titleStr, const char *textStr, const char *helpStr, bool checked) ; } +// end of namespace povwin #endif // PVDIALOG_H_INCLUDED diff --git a/windows/pvdisplay.cpp b/windows/pvdisplay.cpp index 99fe17f52..3c58f7598 100644 --- a/windows/pvdisplay.cpp +++ b/windows/pvdisplay.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -100,6 +100,7 @@ extern HPALETTE hPalBitmap ; extern WINDOWPLACEMENT mainwin_placement ; } +// end of namespace povwin //////////////////////////////////////////////////////////////////////////////////////// // @@ -112,7 +113,7 @@ namespace pov_frontend using namespace povwin; -shared_ptr gDisplay; +std::shared_ptr gDisplay; BitmapInfo WinLegacyDisplay::m_BitmapTemplate; @@ -1251,3 +1252,4 @@ HPALETTE WinLegacyDisplay::CreatePalette (RGBQUAD *rgb, int entries, bool use8bp } } +// end of namespace pov_frontend diff --git a/windows/pvdisplay.h b/windows/pvdisplay.h index 1caf990c1..d38f73d42 100644 --- a/windows/pvdisplay.h +++ b/windows/pvdisplay.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,8 @@ #ifndef __PVDISPLAY_H__ #define __PVDISPLAY_H__ +#include + #include #include "vfe.h" @@ -46,18 +48,18 @@ namespace pov_frontend using namespace vfe; using namespace povwin; - extern shared_ptr gDisplay; + extern std::shared_ptr gDisplay; class WinDisplay : public vfeDisplay { public: WinDisplay(unsigned int w, unsigned int h, vfeSession *session, bool visible) : vfeDisplay(w, h, session, visible), m_Handle (NULL) {}; - virtual ~WinDisplay() {} ; + virtual ~WinDisplay() override {} ; virtual bool CreateRenderWindow (void) = 0; - virtual void Close() = 0; - virtual void Show() = 0; - virtual void Hide() = 0; + virtual void Close() override = 0; + virtual void Show() override = 0; + virtual void Hide() override = 0; virtual bool TakeOver(WinDisplay *display) = 0; virtual bool IsVisible() { return (m_Handle != NULL) && (IsWindowVisible (m_Handle)) ; } virtual HWND GetHandle() { return m_Handle; } @@ -70,33 +72,33 @@ namespace pov_frontend HWND m_AuxHandle; }; - class WinLegacyDisplay : public WinDisplay + class WinLegacyDisplay final : public WinDisplay { public: WinLegacyDisplay(unsigned int w, unsigned int h, vfeSession *session, bool visible); - virtual ~WinLegacyDisplay(); + virtual ~WinLegacyDisplay() override; - void Initialise(); - void Close(); - void Show(); - void Hide(); - bool TakeOver(WinDisplay *display); - void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour); - void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour); - void Clear(); - void SetRenderState(bool IsRendering); - bool CreateRenderWindow (void); + void Initialise() override; + void Close() override; + void Show() override; + void Hide() override; + bool TakeOver(WinDisplay *display) override; + void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour) override; + void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour) override; + void Clear() override; + void SetRenderState(bool IsRendering) override; + bool CreateRenderWindow (void) override; static LRESULT CALLBACK StaticWindowProc (HWND handle, UINT message, WPARAM wParam, LPARAM lParam); static HPALETTE CreatePalette (RGBQUAD *rgb, int entries, bool use8bpp); BITMAPINFOHEADER& GetBMIH(void) { return m_Bitmap.header; } unsigned char *GetBitmapSurface() { return m_BitmapSurface; } protected: - LRESULT WindowProc (UINT message, WPARAM wParam, LPARAM lParam); + virtual LRESULT WindowProc (UINT message, WPARAM wParam, LPARAM lParam) override; void InvalidatePixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2); - inline void SetPixel (unsigned int x, unsigned int y, uchar colour); + inline void SetPixel (unsigned int x, unsigned int y, unsigned char colour); inline void SetPixel (unsigned int x, unsigned int y, const RGBA8 *colour); unsigned char *m_BitmapSurface ; BitmapInfo m_Bitmap ; @@ -135,5 +137,6 @@ namespace pov_frontend return dynamic_cast(p) ; } } +// end of namespace pov_frontend #endif diff --git a/windows/pvedit.cpp b/windows/pvedit.cpp index f719c9140..20f434388 100644 --- a/windows/pvedit.cpp +++ b/windows/pvedit.cpp @@ -53,6 +53,7 @@ namespace pov_frontend { extern struct ProcessOptions::INI_Parser_Table RenderOptions_INI_Table[]; } +// end of namespace pov_frontend namespace povwin { @@ -311,7 +312,7 @@ char *Get_User_Keywords(const char *DocumentsPath) char str[_MAX_PATH]; char *s; FILE *f; - string result; + std::string result; sprintf(str, "%sini\\user-keywords.txt", DocumentsPath); if ((f = fopen(str, "rt")) == NULL) @@ -570,3 +571,4 @@ const char **EditGetWindowList (void) } } +// end of namespace povwin diff --git a/windows/pvedit.h b/windows/pvedit.h index 31c90d9f8..366dd3796 100644 --- a/windows/pvedit.h +++ b/windows/pvedit.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -146,6 +146,7 @@ void EditSetKeywords (LPCSTR SDLKeywords, LPCSTR INIKeywords) ; const char **EditGetWindowList(void); } +// end of namespace povwin #endif // PVEDIT_H_INCLUDED diff --git a/windows/pvengine.cpp b/windows/pvengine.cpp index 174425856..ad589877a 100644 --- a/windows/pvengine.cpp +++ b/windows/pvengine.cpp @@ -70,14 +70,16 @@ #include #include #include +#include // #define DEVELOPMENT +#include #include #include #include -#include +#include #include "pvengine.h" #include "resource.h" @@ -131,8 +133,9 @@ char *WriteDump(struct _EXCEPTION_POINTERS *pExceptionInfo, bool full, long time namespace pov_frontend { - extern shared_ptr gDisplay; + extern std::shared_ptr gDisplay; } +// end of namespace pov_frontend using namespace pov; using namespace pov_frontend; @@ -166,8 +169,8 @@ bool IsExpired; bool BackendFailedFlag = false; bool PreventSleep = true; char DumpMeta[65536]; -string ErrorMessage ; -string ErrorFilename ; +std::string ErrorMessage ; +std::string ErrorFilename ; unsigned ErrorLine ; unsigned ErrorCol ; unsigned render_priority = CM_RENDERPRIORITY_NORMAL ; @@ -318,7 +321,7 @@ HICON ourIcon ; HICON renderIcon ; HFONT about_font ; HANDLE hMainThread ; -string InputFileName ; +std::string InputFileName ; time_t SecondCountStart ; time_t quit ; HBITMAP hBmpBackground ; @@ -370,8 +373,8 @@ CRITICAL_SECTION critical_section ; // key is the name of an included file (all lower case). // content is the name of the most recent rendered file that caused it to be included. -map IncludeToSourceMap; -map IncludeAlternateDecisionMap; +map IncludeToSourceMap; +map IncludeAlternateDecisionMap; char queued_files [MAX_QUEUE] [_MAX_PATH] ; char dir [_MAX_PATH] ; @@ -497,12 +500,12 @@ SCROLLKEYS key2scroll [] = { -1, -1, -1 } } ; -string StripFilePath (const string& str) +std::string StripFilePath (const std::string& str) { - string::size_type pos = str.find_last_of ("\\/") ; - if (pos == string::npos) + std::string::size_type pos = str.find_last_of ("\\/") ; + if (pos == std::string::npos) return (str) ; - return string (str, pos + 1) ; + return std::string(str, pos + 1); } bool StripPathComponent (char *path, int number) @@ -611,7 +614,7 @@ void SetCaption (LPCSTR str) #ifndef DEVELOPMENT if (Session.GetBackendState() == kRendering && InputFileName.size () > 0) { - string filename = StripFilePath (InputFileName) ; + std::string filename = StripFilePath (InputFileName) ; if (strstr (str, filename.c_str ()) != NULL) { // if the filename is in the caption already, we're probably rendering @@ -632,7 +635,7 @@ void SetCaption (LPCSTR str) #else if (Session.GetBackendState() == kRendering && InputFileName.size () > 0) { - string filename = StripFilePath (InputFileName) ; + std::string filename = StripFilePath (InputFileName) ; if (strstr (str, filename.c_str ()) != NULL) { // if the filename is in the caption already, we're probably rendering @@ -1371,7 +1374,7 @@ bool inferHome (void) return (true) ; } -string getHome(const char* ver) +std::string getHome(const char* ver) { char str[_MAX_PATH]; HKEY key ; @@ -1385,7 +1388,7 @@ string getHome(const char* ver) { RegCloseKey (key) ; appendPathSeparator(str); - return string(str); + return std::string(str); } RegCloseKey (key) ; } @@ -1395,11 +1398,11 @@ string getHome(const char* ver) { RegCloseKey (key) ; appendPathSeparator(str); - return string(str); + return std::string(str); } RegCloseKey (key) ; } - return string(); + return std::string(); } bool copyEditSettings(const char* ver) @@ -2417,7 +2420,7 @@ void render_stopped (void) } if (!running_demo && !demo_mode && !benchmark_mode && !rendering_insert_menu && !running_benchmark && !was_insert_render) { - string ofn = UCS2toSysString (Session.GetOutputFilename()); + std::string ofn = UCS2toSysString (Session.GetOutputFilename()); if (output_to_file && ofn.size () != 0) { sprintf (str, "Output -> '%s'", ofn.c_str ()) ; @@ -2494,7 +2497,7 @@ void render_stopped (void) FileType ft = get_file_type(it->c_str()); if (ft < fileFirstImageType || ft > fileLastImageType) { - pair::iterator, bool> result = IncludeToSourceMap.insert(pair (*it, InputFileName)); + pair::iterator, bool> result = IncludeToSourceMap.insert(pair (*it, InputFileName)); if (result.second == false) result.first->second = InputFileName; } @@ -3869,12 +3872,12 @@ LRESULT CALLBACK PovMainWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM _strlwr(fn); // see if we have a previous decision recorded for this file. - map::const_iterator altit = IncludeAlternateDecisionMap.find(fn); + map::const_iterator altit = IncludeAlternateDecisionMap.find(fn); if (altit == IncludeAlternateDecisionMap.end() || altit->second == true) { // either there is no decision recorded, or the decision was 'yes' // in either case we need to find the alternate filename - map::const_iterator it = IncludeToSourceMap.find(fn); + map::const_iterator it = IncludeToSourceMap.find(fn); if (it != IncludeToSourceMap.end()) { // we've found the alternate filename. do we need to ask the user about it? @@ -3885,7 +3888,7 @@ LRESULT CALLBACK PovMainWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM { case IDYES: // record the decision - IncludeAlternateDecisionMap.insert(pair(fn, true)); + IncludeAlternateDecisionMap.insert(pair(fn, true)); strcpy(source_file_name, it->second.c_str()); break; @@ -3896,7 +3899,7 @@ LRESULT CALLBACK PovMainWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM case IDNO: // record the decision - IncludeAlternateDecisionMap.insert(pair(fn, false)); + IncludeAlternateDecisionMap.insert(pair(fn, false)); break; case IDCANCEL: @@ -5080,6 +5083,7 @@ __int64 LZTimerRawCount (void) #endif // #ifdef _MSC_VER } +// end of namespace povwin static void __cdecl newhandler (void) { @@ -5529,10 +5533,10 @@ int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) if (debugging) debug_output("no pvengine.ini: seeing if there is a %s ini\n", *oldVer) ; - string str(getHome(*oldVer)); + std::string str(getHome(*oldVer)); if (str.empty() == false) { - string oldINIpath = str + "ini\\pvengine.ini"; + std::string oldINIpath = str + "ini\\pvengine.ini"; if (!fileExists(oldINIpath.c_str())) continue; diff --git a/windows/pvengine.h b/windows/pvengine.h index a246847bf..b68c21985 100644 --- a/windows/pvengine.h +++ b/windows/pvengine.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -63,8 +63,9 @@ #include #include +#include + #include "pvfrontend.h" -#include "backend/frame.h" #include "backend/povray.h" #include @@ -258,7 +259,7 @@ typedef struct ushort menuBarBorder ; } pvncStruct ; -class AutoLock +class AutoLock final { public: inline AutoLock (CRITICAL_SECTION& CriticalSection) { m_CriticalSection = &CriticalSection ; EnterCriticalSection (m_CriticalSection) ; } @@ -327,7 +328,7 @@ FileType get_file_type (const char *filename) ; bool is_non_primary_file(const char *filename) ; void read_INI_settings (void) ; void write_INI_settings (bool noreset = false) ; -void cloneOldIni(const std::string oldPath, const std::string newPath); +void cloneOldIni(const std::string& oldPath, const std::string& newPath); void update_menu_for_render (bool rendering) ; void update_queue_status (bool write_files) ; void draw_ordinary_listbox (DRAWITEMSTRUCT *d, bool fitpath) ; @@ -594,6 +595,6 @@ uchar dither8x8 [64] = #endif // #if DECLARE_TABLES } +// end of namespace povwin #endif // PVENGINE_H_INCLUDED - diff --git a/windows/pvfiles.cpp b/windows/pvfiles.cpp index 9b223c4d5..90a86d5b0 100644 --- a/windows/pvfiles.cpp +++ b/windows/pvfiles.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -42,6 +42,7 @@ #include #include +#include #include "pvengine.h" #include "resource.h" @@ -210,3 +211,4 @@ char *save_demo_file (char *s1, char *s2) } } +// end of namespace povwin diff --git a/windows/pvfrontend.cpp b/windows/pvfrontend.cpp index 115d8c44a..befe74e70 100644 --- a/windows/pvfrontend.cpp +++ b/windows/pvfrontend.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -61,11 +61,12 @@ namespace povwin extern bool ErrorNotified; extern bool no_shell_outs; extern bool system_noactive; - extern string ErrorMessage ; - extern string ErrorFilename ; + extern std::string ErrorMessage ; + extern std::string ErrorFilename ; extern unsigned ErrorLine ; extern unsigned ErrorCol ; } +// end of namespace povwin namespace pov_frontend { @@ -138,7 +139,7 @@ void CreateFrontend (void) if (gSession->Initialize(NULL, NULL) != vfeNoError) { gSession->Shutdown(); - string str = gSession->GetErrorString(); + std::string str = gSession->GetErrorString(); delete gSession; gSession = NULL; throw POV_EXCEPTION_STRING (str.c_str()); @@ -162,17 +163,17 @@ void SetupFrontend (void) if (io_restrictions != 0) { for (char **dirspec = WriteDirSpecs ; *dirspec != NULL ; dirspec++) - gSession->AddWritePath (string (*dirspec), true); + gSession->AddWritePath (std::string(*dirspec), true); if (io_restrictions > 1) { - gSession->AddReadPath(string(DocumentsPath), true); - gSession->AddReadPath(string(FontPath) + "\\", false); + gSession->AddReadPath(std::string(DocumentsPath), true); + gSession->AddReadPath(std::string(FontPath) + "\\", false); for (char **dirspec = ReadDirSpecs ; *dirspec != NULL ; dirspec++) - gSession->AddReadPath (string (*dirspec), true); + gSession->AddReadPath (std::string(*dirspec), true); } // allow write to the insert menu directory - string str(DocumentsPath); + std::string str(DocumentsPath); str += "Insert Menu\\"; gSession->AddWritePath (str, true); @@ -308,9 +309,9 @@ bool ProcessSession (int delay) int line; int col; char str[32]; - string errormsg; - string message; - string filename; + std::string errormsg; + std::string message; + std::string filename; vfeSession::MessageType type; while (gSession->GetNextNonStatusMessage (type, message, filename, line, col)) @@ -414,3 +415,4 @@ bool ShelloutsPermitted(void) } } +// end of namespace pov_frontend diff --git a/windows/pvfrontend.h b/windows/pvfrontend.h index 7ccf6bfc0..fa5e90f2e 100644 --- a/windows/pvfrontend.h +++ b/windows/pvfrontend.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -52,5 +52,6 @@ namespace pov_frontend bool MinimizeShellouts(void); bool ShelloutsPermitted(void); } +// end of namespace pov_frontend #endif diff --git a/windows/pvguiext.cpp b/windows/pvguiext.cpp index 76e531c09..a965a71b8 100644 --- a/windows/pvguiext.cpp +++ b/windows/pvguiext.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -710,3 +710,4 @@ BOOL CheckGUIExtLoaded (const char *Name) } } +// end of namespace povwin diff --git a/windows/pvguiext.h b/windows/pvguiext.h index afceb95b5..bea765e94 100644 --- a/windows/pvguiext.h +++ b/windows/pvguiext.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -282,6 +282,6 @@ char *ExternalMenuTip (WPARAM wParam) ; BOOL CheckGUIExtLoaded (const char *Name) ; } +// end of namespace povwin #endif // PVGUIEXT_H_INCLUDED - diff --git a/windows/pvlegal.h b/windows/pvlegal.h index d29acfdc0..fe81efca4 100644 --- a/windows/pvlegal.h +++ b/windows/pvlegal.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -702,3 +702,4 @@ char povlegal_text [] = } ; } +// end of namespace povwin diff --git a/windows/pvmem.cpp b/windows/pvmem.cpp index 304fdb094..baed99699 100644 --- a/windows/pvmem.cpp +++ b/windows/pvmem.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -349,7 +349,8 @@ char *win_strdup(const char *s) #endif // else portion of '#ifdef _DEBUG' #endif // else portion of '#if POV_MEM_STATS == 0 && WIN_MEM_TRACKING == 0' -} // end of namespace povwin +} +// end of namespace povwin #if WIN_MEM_TRACKING diff --git a/windows/pvmem.h b/windows/pvmem.h index 80b0a3a99..90dab19e1 100644 --- a/windows/pvmem.h +++ b/windows/pvmem.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -44,7 +44,7 @@ namespace povwin { -class WinMemStats +class WinMemStats final { public: WinMemStats() { Clear(); } @@ -140,7 +140,7 @@ class WinMemStats typedef WinMemStats PovMemStats; -class WinHeap +class WinHeap final { public: WinHeap() @@ -227,7 +227,7 @@ class WinHeap CRITICAL_SECTION m_CritSec; }; -class HeapLock +class HeapLock final { public: HeapLock(WinHeap *wh) : m_WinHeap(wh) { m_WinHeap->Lock(); } @@ -236,7 +236,7 @@ class HeapLock WinHeap *m_WinHeap; }; -class WinMemBlock +class WinMemBlock final { public: __declspec(nothrow) WinMemBlock(const void *data, int line) @@ -353,10 +353,11 @@ class WinMemBlock static const size_t BlockPadding = 0; # endif - WinMemBlock() {} // not available - void *operator new (size_t len) {} // not available + WinMemBlock() = delete; + void *operator new (size_t len) = delete; }; } +// end of namespace povwin #endif // POVRAY_WINDOWS_PVMEM_H diff --git a/windows/pvmenu.cpp b/windows/pvmenu.cpp index bd1252cf7..fd159d4f6 100644 --- a/windows/pvmenu.cpp +++ b/windows/pvmenu.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -279,3 +279,4 @@ void build_editor_menu (HMENU hMenu) } } +// end of namespace povwin diff --git a/windows/pvmisc.cpp b/windows/pvmisc.cpp index b59a43e82..455fd454a 100644 --- a/windows/pvmisc.cpp +++ b/windows/pvmisc.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -72,6 +72,7 @@ namespace povwin using std::map; using std::endl; +using std::string; extern int alert_sound ; extern int message_xchar ; @@ -658,7 +659,7 @@ void write_INI_settings (bool noreset) // and never use it. // // TODO: add replace regex to alter paths from old to new where appropriate -void cloneOldIni(string oldPath, string newPath) +void cloneOldIni(const string& oldPath, const string& newPath) { bool keep = false; smatch what; @@ -717,7 +718,7 @@ void cloneOldIni(string oldPath, string newPath) #else -void cloneOldIni(string oldPath, string newPath) +void cloneOldIni(const string& oldPath, const string& newPath) { bool keep = false; size_t pos; @@ -1543,5 +1544,4 @@ bool ShowRestrictionMessage (char *Message, char *Dir) } } - - +// end of namespace povwin diff --git a/windows/pvtext.cpp b/windows/pvtext.cpp index bbcb7e697..e6d973885 100644 --- a/windows/pvtext.cpp +++ b/windows/pvtext.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -2016,3 +2016,4 @@ void say_status_message (int section, const char *message) } } +// end of namespace povwin diff --git a/windows/pvupdate.cpp b/windows/pvupdate.cpp index dec135ad1..ad2af3dbc 100644 --- a/windows/pvupdate.cpp +++ b/windows/pvupdate.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -67,8 +67,6 @@ #define SCRIPTPATH "/updates/checkv2" -using std::string; - namespace povwin { @@ -102,7 +100,7 @@ bool InternetConnected (void) } // -1 == error, 0 == no update, 1 == update -int IsUpdateAvailable (bool SendSysinfo, char *CurrentVersion, string& NewVersion, string& Info) +int IsUpdateAvailable (bool SendSysinfo, char *CurrentVersion, std::string& NewVersion, std::string& Info) { int result = -1 ; char poststr [2048] ; @@ -231,8 +229,8 @@ int IsUpdateAvailable (bool SendSysinfo, char *CurrentVersion, string& NewVersio result = 1 ; Info.clear(); NewVersion = reply + 4; - string::size_type pos = NewVersion.find(' '); - if (pos != string::npos) + std::string::size_type pos = NewVersion.find(' '); + if (pos != std::string::npos) { Info = NewVersion.substr(pos); NewVersion.resize(pos); @@ -257,4 +255,5 @@ int IsUpdateAvailable (bool SendSysinfo, char *CurrentVersion, string& NewVersio return (result) ; } -} // end of namespace povwin +} +// end of namespace povwin diff --git a/windows/rtrsupport/rtrsupport.cpp b/windows/rtrsupport/rtrsupport.cpp index acb44170a..9b5b14bae 100644 --- a/windows/rtrsupport/rtrsupport.cpp +++ b/windows/rtrsupport/rtrsupport.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -54,11 +54,9 @@ std::string VideoSourceName; namespace povwin { -using namespace pov; - // this code has been stubbed out: need to re-implement -size_t GetVideoSourceNames(vector& result) +size_t GetVideoSourceNames(std::vector& result) { return 0; } @@ -77,5 +75,6 @@ void NextFrame(void) } } +// end of namespace povwin #endif diff --git a/windows/rtrsupport/rtrsupport.h b/windows/rtrsupport/rtrsupport.h index 966871c8f..de833c788 100644 --- a/windows/rtrsupport/rtrsupport.h +++ b/windows/rtrsupport/rtrsupport.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -36,6 +36,9 @@ #ifndef __RTRSUPPORT_H__ #define __RTRSUPPORT_H__ +#include +#include + namespace povwin { size_t GetVideoSourceNames(std::vector& result); @@ -43,5 +46,6 @@ namespace povwin const std::string& GetVideoSourceName(void); void NextFrame(void); } +// end of namespace povwin #endif diff --git a/windows/rtrsupport/vidcapimpl.cpp b/windows/rtrsupport/vidcapimpl.cpp index dd27ceb0c..d4fd75917 100644 --- a/windows/rtrsupport/vidcapimpl.cpp +++ b/windows/rtrsupport/vidcapimpl.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -66,7 +66,7 @@ VideoCaptureImpl::~VideoCaptureImpl() { } -Image *VideoCaptureImpl::Init(const char *params, Image::ReadOptions& options, bool doubleBuffer) +Image *VideoCaptureImpl::Init(const char *params, ImageReadOptions& options, bool doubleBuffer) { return NULL; } @@ -80,6 +80,7 @@ bool VideoCaptureImpl::WaitFrame(int count, unsigned int timeout) return false; } -} // end of namespace pov +} +// end of namespace pov #endif diff --git a/windows/vs2015/povbackend.vcxproj b/windows/vs2015/povbackend.vcxproj index f257b4955..8707cf355 100644 --- a/windows/vs2015/povbackend.vcxproj +++ b/windows/vs2015/povbackend.vcxproj @@ -433,10 +433,13 @@ + + + + - @@ -447,6 +450,8 @@ + + diff --git a/windows/vs2015/povbackend.vcxproj.filters b/windows/vs2015/povbackend.vcxproj.filters index 546e738b2..abbf2109b 100644 --- a/windows/vs2015/povbackend.vcxproj.filters +++ b/windows/vs2015/povbackend.vcxproj.filters @@ -119,9 +119,6 @@ Backend Headers - - Backend Headers - Backend Headers @@ -194,5 +191,23 @@ Backend Headers\Control + + Backend Headers\Scene + + + Backend Headers\Scene + + + Backend Headers\Control + + + Backend Headers\Scene + + + Backend Headers\Lighting + + + Backend Headers\Control + \ No newline at end of file diff --git a/windows/vs2015/povbase.vcxproj b/windows/vs2015/povbase.vcxproj index a33b03591..2cb007a33 100644 --- a/windows/vs2015/povbase.vcxproj +++ b/windows/vs2015/povbase.vcxproj @@ -388,6 +388,7 @@ + @@ -445,28 +446,41 @@ + + + + + + + + + + + + + diff --git a/windows/vs2015/povbase.vcxproj.filters b/windows/vs2015/povbase.vcxproj.filters index 1f241f597..21ff34f0c 100644 --- a/windows/vs2015/povbase.vcxproj.filters +++ b/windows/vs2015/povbase.vcxproj.filters @@ -144,6 +144,9 @@ Base source\Image + + Base source + @@ -284,5 +287,44 @@ Base Headers\Image + + Base Headers + + + Base Headers + + + Base Headers + + + Base Headers\Image + + + Base Headers + + + Base Headers + + + Base Headers\Image + + + Base Headers + + + Base Headers\Image + + + Base Headers + + + Base Headers + + + Base Headers + + + Base Headers + \ No newline at end of file diff --git a/windows/vs2015/povcore.vcxproj b/windows/vs2015/povcore.vcxproj index 4949cd7e4..56aaed906 100644 --- a/windows/vs2015/povcore.vcxproj +++ b/windows/vs2015/povcore.vcxproj @@ -429,6 +429,7 @@ + @@ -479,15 +480,19 @@ + + + + @@ -495,6 +500,7 @@ + @@ -511,9 +517,11 @@ + + @@ -523,6 +531,7 @@ + @@ -546,6 +555,7 @@ + diff --git a/windows/vs2015/povcore.vcxproj.filters b/windows/vs2015/povcore.vcxproj.filters index ca4c0396f..3e9736386 100644 --- a/windows/vs2015/povcore.vcxproj.filters +++ b/windows/vs2015/povcore.vcxproj.filters @@ -272,6 +272,9 @@ Core Source\Material + + Core Source\Math + @@ -496,5 +499,32 @@ Core Headers\Material + + Core Headers + + + Core Headers\Scene + + + Core Headers\Bounding + + + Core Headers\Bounding + + + Core Headers\Render + + + Core Headers\Shape + + + Core Headers\Lighting + + + Core Headers\Material + + + Core Headers\Support + \ No newline at end of file diff --git a/windows/vs2015/povfrontend.vcxproj b/windows/vs2015/povfrontend.vcxproj index 59357a4b8..e5293756c 100644 --- a/windows/vs2015/povfrontend.vcxproj +++ b/windows/vs2015/povfrontend.vcxproj @@ -411,6 +411,7 @@ + @@ -419,6 +420,7 @@ + diff --git a/windows/vs2015/povfrontend.vcxproj.filters b/windows/vs2015/povfrontend.vcxproj.filters index 72873eeec..fa7db9b7d 100644 --- a/windows/vs2015/povfrontend.vcxproj.filters +++ b/windows/vs2015/povfrontend.vcxproj.filters @@ -101,5 +101,11 @@ Frontend Headers + + Frontend Headers + + + Frontend Headers + \ No newline at end of file diff --git a/windows/vs2015/povparser.vcxproj b/windows/vs2015/povparser.vcxproj index ef1d47491..e90289687 100644 --- a/windows/vs2015/povparser.vcxproj +++ b/windows/vs2015/povparser.vcxproj @@ -426,6 +426,7 @@ + diff --git a/windows/vs2015/povparser.vcxproj.filters b/windows/vs2015/povparser.vcxproj.filters index 0a7230375..d050cbe31 100644 --- a/windows/vs2015/povparser.vcxproj.filters +++ b/windows/vs2015/povparser.vcxproj.filters @@ -43,6 +43,9 @@ Parser Headers + + Parser Headers + diff --git a/windows/vs2015/povplatform.vcxproj b/windows/vs2015/povplatform.vcxproj index 3deeba43f..b95f78ef0 100644 --- a/windows/vs2015/povplatform.vcxproj +++ b/windows/vs2015/povplatform.vcxproj @@ -376,6 +376,7 @@ + diff --git a/windows/vs2015/povvm.vcxproj b/windows/vs2015/povvm.vcxproj index 4cc830d31..96717ec7c 100644 --- a/windows/vs2015/povvm.vcxproj +++ b/windows/vs2015/povvm.vcxproj @@ -414,6 +414,7 @@ + diff --git a/windows/vs2015/povvm.vcxproj.filters b/windows/vs2015/povvm.vcxproj.filters index 48132ac4a..a5e77b9fc 100644 --- a/windows/vs2015/povvm.vcxproj.filters +++ b/windows/vs2015/povvm.vcxproj.filters @@ -27,6 +27,9 @@ VM Headers + + VM Headers + diff --git a/windows/winprecomp.h b/windows/winprecomp.h index c6286bd90..81224aa06 100644 --- a/windows/winprecomp.h +++ b/windows/winprecomp.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -45,17 +45,23 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED + #define POVWIN_FILE #define _CRT_RAND_S #define _WIN32_IE COMMONCTRL_VERSION +// C++ variants of C standard header files #include #include #include #include + +// C++ standard header files #include #include #include +#include #include #include #include @@ -80,14 +86,14 @@ #include #include +// Boost header files #include #include #include #include -#include -#include +#if POV_MULTITHREADED #include #include +#endif #include -#include