Commit 92218413 authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Merge branch feature/jorgen.lind/warnings_settings with refs/heads/master into...

Merge branch feature/jorgen.lind/warnings_settings with refs/heads/master into refs/merge-requests/121/train
parents 7be360b6 758642ca
Pipeline #1259 passed with stages
in 2 minutes and 45 seconds
......@@ -45,6 +45,7 @@ function(BuildExternal name version depends source_dir install_libs_release runt
endforeach()
set_property(GLOBAL APPEND PROPERTY OPENVDS_INCLUDE_LIBRARIES "${INSTALL_INT_CONFIG}/include")
set_property(GLOBAL APPEND PROPERTY OPENVDS_DEPENDENCY_TARGETS "${name}")
if (cmake_args)
set(cmake_arg_complete "${cmake_args};")
......
function(setWarningFlagsForTarget target)
if (DISABLE_STRICT_WARNINGS)
return()
endif()
if (MSVC)
target_compile_options(${target} PRIVATE /W3 /WX)
else()
target_compile_options(${target} PRIVATE -Wall -Wextra -pedantic -Werror -Wno-unused-parameter -fms-extensions)
endif()
endfunction()
......@@ -42,7 +42,6 @@ else()
endif()
if (Python3_FOUND)
message(${Python3_EXECUTABLE})
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
else()
message("Failed to find Python3 interpreter. Disabling Python build")
......@@ -56,6 +55,7 @@ option(BUILD_EXAMPLES "Build OpenVDS example projects" ON)
option(BUILD_TESTS "Build OpenVDS tests" ON)
option(BUILD_DOCS "Build OpenVDS docs" OFF)
option(ENABLE_RUNPATH_ORIGIN "On Linux make the install have ORIGIN as RUNPATH" ON)
option(DISABLE_STRICT_WARNINGS "Disable strict warnings settings. This includes making warnings to errors." OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
......@@ -66,6 +66,7 @@ define_property(GLOBAL PROPERTY OPENVDS_RUNTIME_LIBS_DEBUG BRIEF_DOCS "Runtime
define_property(GLOBAL PROPERTY OPENVDS_LINK_LIBRARIES_RELEASE BRIEF_DOCS "OpenVDS link libraries" FULL_DOCS "Files OpenVDS will link with")
define_property(GLOBAL PROPERTY OPENVDS_LINK_LIBRARIES_DEBUG BRIEF_DOCS "OpenVDS link libraries" FULL_DOCS "Files OpenVDS will link with")
define_property(GLOBAL PROPERTY OPENVDS_INCLUDE_LIBRARIES BRIEF_DOCS "OpenVDS include libraries" FULL_DOCS "Include paths for 3rdparty")
define_property(GLOBAL PROPERTY OPENVDS_DEPENDENCY_TARGETS BRIEF_DOCS "Dependency targets for OpenVDS" FULL_DOCS "Targets that OpenVDS needs to build first")
if(CMAKE_VS_PLATFORM_TOOLSET)
string(REGEX REPLACE "^v" "" MSVC_TOOLSET_VERSION_LOCAL "${CMAKE_VS_PLATFORM_TOOLSET}")
......@@ -99,6 +100,8 @@ option(BUILD_ZLIB "Build zlib" ${DEFAULT_BUILD_ZLIB})
option(BUILD_CURL "Build libcurl as part of the openVDS build" ${DEFAULT_BUILD_CURL})
option(BUILD_UV "Build libuv as part of the openVDS build" ${DEFAULT_BUILD_UV})
include(CMake/SetWarnings.cmake)
include(CMake/Fetch3rdPartyInBuild.cmake)
Fetch3rdParty()
......
......@@ -101,11 +101,22 @@ set (EXPORTED_HEADER_FILES
OpenVDS/SimplexNoiseKernel.h
)
if (MSVC)
set(DISABLE_WARNING_FLAG "/w")
else()
set(DISABLE_WARNING_FLAG "-w")
endif()
set_source_files_properties(VDS/FSE/entropy_common.cpp PROPERTIES COMPILE_FLAGS ${DISABLE_WARNING_FLAG})
set_source_files_properties(VDS/FSE/fse_decompress.cpp PROPERTIES COMPILE_FLAGS ${DISABLE_WARNING_FLAG})
add_library(openvds_objects OBJECT
${PRIVATE_HEADER_FILES}
${EXPORTED_HEADER_FILES}
${SOURCE_FILES})
setWarningFlagsForTarget(openvds_objects)
function(compileInTarget to_target source_target)
get_target_property(src_sources ${source_target} SOURCES)
get_target_property(src_include ${source_target} INTERFACE_INCLUDE_DIRECTORIES)
......@@ -113,8 +124,9 @@ function(compileInTarget to_target source_target)
foreach (src_file ${src_sources})
set(complete_file "${src_dir}/${src_file}")
target_sources(${to_target} PRIVATE ${complete_file})
set_source_files_properties(${complete_file} PROPERTES COMPILE_FLAGS ${DISABLE_WARNING_FLAG})
endforeach()
target_include_directories(${to_target} PRIVATE ${src_include})
target_include_directories(${to_target} SYSTEM PRIVATE ${src_include})
endfunction()
compileInTarget(openvds_objects fmt::fmt)
......@@ -129,10 +141,14 @@ get_property(link_3rdparty_debug GLOBAL PROPERTY OPENVDS_LINK_LIBRARIES_DEBUG)
get_property(runtime_3rdparty_release GLOBAL PROPERTY OPENVDS_RUNTIME_LIBS_RELEASE)
get_property(runtime_3rdparty_debug GLOBAL PROPERTY OPENVDS_RUNTIME_LIBS_DEBUG)
get_property(include_3rdparty GLOBAL PROPERTY OPENVDS_INCLUDE_LIBRARIES)
get_property(dependency_targets_3rdparty GLOBAL PROPERTY OPENVDS_DEPENDENCY_TARGETS)
add_dependencies(openvds_objects aws-cpp-sdk azure-storage)
foreach(DEP ${dependency_targets_3rdparty})
add_dependencies(openvds_objects ${DEP})
endforeach()
target_include_directories(openvds_objects SYSTEM PRIVATE ${include_3rdparty} "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(openvds_objects PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(openvds_objects SYSTEM PRIVATE ${include_3rdparty})
target_compile_definitions(openvds_objects PRIVATE openvds_EXPORTS)
target_link_libraries(openvds_objects PUBLIC Threads::Threads)
......
......@@ -79,7 +79,7 @@ static size_t curlReadCallback(char *buffer, size_t size, size_t nitems, void *u
static void curlAddRequests(UVEventLoopData *eventLoopData)
{
int maxConcurrentRequests = 64;
int to_add = maxConcurrentRequests - eventLoopData->processingRequests.size();
int to_add = maxConcurrentRequests - int(eventLoopData->processingRequests.size());
assert(to_add >= 0);
to_add = std::min(to_add, int(eventLoopData->queuedRequests.size()));
for (int i = 0; i < to_add; i++)
......@@ -533,6 +533,29 @@ void CurlDownloadHandler::handleDone(int responseCode, const Error &error)
downloadRequest->m_waitForFinish.notify_all();
}
static std::string trimInBothEnds(const std::string& str)
{
auto it_begin = std::find_if(str.begin(), str.end(), [](const char a) { return !std::isspace(a); });
auto it_end = std::find_if(str.rbegin(), str.rend(), [](const char a) { return !std::isspace(a); }).base();
if (it_end < it_begin)
return std::string();
return std::string(it_begin, it_end);
}
static void getKeyValueFromLine(const char *line, size_t size, std::string &key, std::string &value, char delimiter)
{
const char *end = line + size;
const char *colon = std::find(line, end, delimiter);
if (colon >= end - 1 )
return;
std::string k(line, colon);
std::string v(colon + 1, end);
key = trimInBothEnds(k);
value = trimInBothEnds(v);
}
void CurlDownloadHandler::handleHeaderData(char* b, size_t size)
{
std::string name, value;
......
......@@ -42,29 +42,6 @@
namespace OpenVDS
{
static std::string trimInBothEnds(const std::string& str)
{
auto it_begin = std::find_if(str.begin(), str.end(), [](const char a) { return !std::isspace(a); });
auto it_end = std::find_if(str.rbegin(), str.rend(), [](const char a) { return !std::isspace(a); }).base();
if (it_end < it_begin)
return std::string();
return std::string(it_begin, it_end);
}
static void getKeyValueFromLine(const char *line, size_t size, std::string &key, std::string &value, char delimiter)
{
const char *end = line + size;
const char *colon = std::find(line, end, delimiter);
if (colon >= end - 1 )
return;
std::string k(line, colon);
std::string v(colon + 1, end);
key = trimInBothEnds(k);
value = trimInBothEnds(v);
}
class IOManagerCurl;
struct UVEventLoopData;
......@@ -132,7 +109,6 @@ struct CurlDownloadHandler : public CurlEasyHandler
, request(request)
, url(std::move(url))
, headers(std::move(headers))
, data(std::move(data))
, metaKeyPrefixTrim(std::move(metaKeyPrefixTrim))
, toISO8601DateTransformer(toISO8601DateTransformer)
, verb(verb)
......
......@@ -18,7 +18,9 @@
#include "File.h"
#ifdef HAVE_SYNCFS
#define _GNU_SOURCE
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#endif
#include <sys/mman.h>
......@@ -42,18 +44,6 @@ static std::string ErrorToString(int error)
return std::string(strerror(error));
}
static void SetIoError(int error, Error &io_error)
{
io_error.code = error;
io_error.string = ErrorToString(error);
}
static void SetIoError(int error, std::string &error_string_prefix, Error &io_error)
{
io_error.code = error;
io_error.string = error_string_prefix + ErrorToString(error);
}
template<size_t N>
static void SetIoError(int error, const char (&error_string_prefix)[N], Error &io_error)
{
......@@ -93,14 +83,14 @@ private:
m_SigactionNew.sa_handler = SystemFileView::SIGBUSHandler;
int iRetval = sigaction(SIGBUS, &m_SigactionNew, &m_SigactionOld);
(void)iRetval;
assert(iRetval == 0);
}
~SignalHandlerInstaller()
{
int iRetval = sigaction(SIGBUS, &m_SigactionOld, NULL);
(void)iRetval;
assert(iRetval == 0);
}
};
......@@ -125,7 +115,8 @@ public:
off_t nAdjustedOffset = nPos - nDelta;
int iFD = *reinterpret_cast<int*>(&pFileMappingObject);
int iFD;
memcpy(&iFD, &pFileMappingObject, sizeof(iFD));
int iFlags = MAP_PRIVATE;
......@@ -227,7 +218,7 @@ void File::Close()
assert(IsOpen());
int fd = (int)(intptr_t)_pxPlatformHandle;
bool isOK = ::close(fd) == 0;
::close(fd);
_pxPlatformHandle = 0;
_cFileName.clear();
......@@ -352,6 +343,7 @@ FileView *File::CreateFileView(int64_t nPos, int64_t nSize, bool isPopulate, Err
if (error.code)
{
bool deleted = FileView::RemoveReference(ret);
(void)deleted;
assert(deleted);
ret = nullptr;
}
......
......@@ -15,7 +15,7 @@ struct M4
DoubleVector4 data[4];
};
static void fastInvert(M4 &m)
inline void fastInvert(M4 &m)
{
DoubleVector3 cT(m.data[3].X, m.data[3].Y, m.data[3].Z);
......@@ -35,7 +35,7 @@ static void fastInvert(M4 &m)
if (fabs(fDet) <= rEpsilon)
{
memset(&m, 0, sizeof(m));
m = {};
return;
}
......
......@@ -20,6 +20,16 @@
#include <stddef.h>
#include <tuple>
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpedantic"
#endif
namespace OpenVDS
{
......@@ -161,3 +171,11 @@ template<size_t N>
using DoubleVector = Vector<double, N>;
}
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
......@@ -41,6 +41,11 @@ class VolumeDataLayout;
struct OPENVDS_EXPORT VolumeIndexerData
{
VolumeIndexerData()
: valueRangeMin(0)
, valueRangeMax(0)
{}
VolumeIndexerData(const VolumeDataPage *page,
int32_t channelIndex,
int32_t lod,
......@@ -804,6 +809,8 @@ struct VolumeIndexerBase : public VolumeIndexerData
///////////////////////////// Constructors /////////////////////////////
VolumeIndexerBase()
{}
VolumeIndexerBase(const VolumeDataPage *page,
int32_t channelIndex,
......@@ -821,20 +828,21 @@ struct VolumeIndexerBase : public VolumeIndexerData
/// @param iLOD the LOD for this indexer
/// @return the created indexer
///
static VolumeIndexerBase<N> CreateTempBufferIndexer(int anVoxelMin[6], int anVoxelMax[6], int iLOD = 0)
static VolumeIndexerBase<N> CreateTempBufferIndexer(int (&anVoxelMin)[6], int (&anVoxelMax)[6], int iLOD = 0)
{
VolumeIndexerBase<N> newIndexer;
newIndexer.lod = iLOD;
newIndexer.valueRangeMin = 0;
newIndexer.valueRangeMax = 0;
//All of these static casts are to work around a bug in gcc
static_cast<VolumeIndexerData &>(newIndexer).lod = iLOD;
static_cast<VolumeIndexerData &>(newIndexer).valueRangeMin = 0;
static_cast<VolumeIndexerData &>(newIndexer).valueRangeMax = 0;
//initialize datablock info
for (int iDataBlockDim = 0; iDataBlockDim < DataBlockDimensionality_Max; iDataBlockDim++)
{
newIndexer.dimensionMap[iDataBlockDim] = -1;
newIndexer.dataBlockSamples[iDataBlockDim] = 1;
newIndexer.dataBlockAllocatedSize[iDataBlockDim] = 1;
static_cast<VolumeIndexerData &>(newIndexer).dimensionMap[iDataBlockDim] = -1;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockSamples[iDataBlockDim] = 1;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockAllocatedSize[iDataBlockDim] = 1;
}
{
......@@ -843,32 +851,32 @@ struct VolumeIndexerBase : public VolumeIndexerData
int iDataBlockDim = 0;
for (int iDimension = 0; iDimension < Dimensionality_Max; iDimension++)
{
newIndexer.voxelMin[iDimension] = anVoxelMin[iDimension];
newIndexer.voxelMax[iDimension] = anVoxelMax[iDimension];
newIndexer.axisNumSamples[iDimension] = anVoxelMax[iDimension] - anVoxelMin[iDimension];
newIndexer.pitch[iDimension] = pitch;
newIndexer.bitPitch[iDimension] = bitPitch;
static_cast<VolumeIndexerData &>(newIndexer).voxelMin[iDimension] = anVoxelMin[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).voxelMax[iDimension] = anVoxelMax[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).axisNumSamples[iDimension] = anVoxelMax[iDimension] - anVoxelMin[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).pitch[iDimension] = pitch;
static_cast<VolumeIndexerData &>(newIndexer).bitPitch[iDimension] = bitPitch;
pitch *= (anVoxelMax[iDimension] - anVoxelMin[iDimension] + (1 << iLOD) - 1) >> iLOD;
bitPitch = pitch * 8;
newIndexer.coordinateMin[iDimension] = 0;
newIndexer.coordinateMax[iDimension] = 0;
static_cast<VolumeIndexerData &>(newIndexer).coordinateMin[iDimension] = 0;
static_cast<VolumeIndexerData &>(newIndexer).coordinateMax[iDimension] = 0;
newIndexer.isDimensionLODDecimated[iDimension] = false;
static_cast<VolumeIndexerData &>(newIndexer).isDimensionLODDecimated[iDimension] = false;
newIndexer.localChunkSamples[iDimension] = (anVoxelMax[iDimension] - anVoxelMin[iDimension] + (1 << iLOD) - 1) >> iLOD;
newIndexer.localChunkAllocatedSize[iDimension] = newIndexer.localChunkSamples[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension] = (anVoxelMax[iDimension] - anVoxelMin[iDimension] + (1 << iLOD) - 1) >> iLOD;
static_cast<VolumeIndexerData &>(newIndexer).localChunkAllocatedSize[iDimension] = static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension];
if (newIndexer.localChunkSamples[iDimension] > 1)
if (static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension] > 1)
{
//Don't allow temp buffers with more than 4D data blocks
assert(iDataBlockDim < DataBlockDimensionality_Max);
// dimension has size, make sure it's mapped
newIndexer.dataBlockSamples[iDataBlockDim] = newIndexer.localChunkSamples[iDimension];
newIndexer.dataBlockAllocatedSize[iDataBlockDim] = newIndexer.localChunkSamples[iDimension];
newIndexer.dimensionMap[iDataBlockDim] = iDimension;
newIndexer.isDimensionLODDecimated[iDimension] = true;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockSamples[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).dataBlockAllocatedSize[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).dimensionMap[iDataBlockDim] = iDimension;
static_cast<VolumeIndexerData &>(newIndexer).isDimensionLODDecimated[iDimension] = true;
iDataBlockDim++;
}
......@@ -876,12 +884,12 @@ struct VolumeIndexerBase : public VolumeIndexerData
}
//set pitches
newIndexer.dataBlockPitch[0] = 1;
newIndexer.dataBlockBitPitch[0] = 1;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[0] = 1;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockBitPitch[0] = 1;
for (int iDataBlockDim = 1; iDataBlockDim < DataBlockDimensionality_Max; iDataBlockDim++)
{
newIndexer.dataBlockPitch[iDataBlockDim] = newIndexer.dataBlockPitch[iDataBlockDim - 1] * newIndexer.dataBlockSamples[iDataBlockDim - 1];
newIndexer.dataBlockBitPitch[iDataBlockDim] = newIndexer.dataBlockPitch[iDataBlockDim] * 8;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[iDataBlockDim - 1] * static_cast<VolumeIndexerData &>(newIndexer).dataBlockSamples[iDataBlockDim - 1];
static_cast<VolumeIndexerData &>(newIndexer).dataBlockBitPitch[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[iDataBlockDim] * 8;
}
......@@ -895,26 +903,27 @@ struct VolumeIndexerBase : public VolumeIndexerData
///
static VolumeIndexerBase<N> CreateTempBufferIndexer(const VolumeIndexerBase<N> &indexer)
{
VolumeIndexerBase<N> newIndexer(indexer);
VolumeIndexerBase<N> newIndexer;
//All of these static casts are to work around a bug in gcc
// reset pitches
newIndexer.dataBlockPitch[0] = 1;
newIndexer.dataBlockBitPitch[0] = 1;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[0] = 1;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockBitPitch[0] = 1;
for (int iDataBlockDim = 1; iDataBlockDim < DataBlockDimensionality_Max; iDataBlockDim++)
{
newIndexer.dataBlockPitch[iDataBlockDim] = newIndexer.dataBlockPitch[iDataBlockDim - 1] * indexer.dataBlockSamples[iDataBlockDim - 1];
newIndexer.dataBlockBitPitch[iDataBlockDim] = newIndexer.dataBlockPitch[iDataBlockDim] * 8;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[iDataBlockDim - 1] * indexer.dataBlockSamples[iDataBlockDim - 1];
static_cast<VolumeIndexerData &>(newIndexer).dataBlockBitPitch[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[iDataBlockDim] * 8;
}
for (int iDataBlockDim = 0; iDataBlockDim < DataBlockDimensionality_Max; iDataBlockDim++)
{
newIndexer.dataBlockAllocatedSize[iDataBlockDim] = newIndexer.dataBlockSamples[iDataBlockDim];
static_cast<VolumeIndexerData &>(newIndexer).dataBlockAllocatedSize[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).dataBlockSamples[iDataBlockDim];
int iDimension = indexer.dimensionMap[iDataBlockDim];
if (iDimension >= 0 && iDimension < Dimensionality_Max)
{
newIndexer.pitch[iDimension] = newIndexer.dataBlockPitch[iDataBlockDim];
newIndexer.bitPitch[iDimension] = newIndexer.dataBlockBitPitch[iDataBlockDim];
newIndexer.localChunkAllocatedSize[iDimension] = newIndexer.dataBlockSamples[iDataBlockDim];
static_cast<VolumeIndexerData &>(newIndexer).pitch[iDimension] = static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[iDataBlockDim];
static_cast<VolumeIndexerData &>(newIndexer).bitPitch[iDimension] = static_cast<VolumeIndexerData &>(newIndexer).dataBlockBitPitch[iDataBlockDim];
static_cast<VolumeIndexerData &>(newIndexer).localChunkAllocatedSize[iDimension] = static_cast<VolumeIndexerData &>(newIndexer).dataBlockSamples[iDataBlockDim];
}
}
......@@ -930,14 +939,15 @@ struct VolumeIndexerBase : public VolumeIndexerData
///
static VolumeIndexerBase<N> CreateTempBufferIndexer(const VolumeIndexerBase<N> &indexer, int anNewVoxelMin[6], int anNewVoxelMax[6])
{
VolumeIndexerBase<N> newIndexer(indexer);
VolumeIndexerBase<N> newIndexer;
//All of these static casts are to work around a bug in gcc
//initialize datablock info
for (int iDataBlockDim = 0; iDataBlockDim < DataBlockDimensionality_Max; iDataBlockDim++)
{
newIndexer.dimensionMap[iDataBlockDim] = -1;
newIndexer.dataBlockSamples[iDataBlockDim] = 1;
newIndexer.dataBlockAllocatedSize[iDataBlockDim] = 1;
static_cast<VolumeIndexerData &>(newIndexer).dimensionMap[iDataBlockDim] = -1;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockSamples[iDataBlockDim] = 1;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockAllocatedSize[iDataBlockDim] = 1;
}
{
......@@ -945,42 +955,42 @@ struct VolumeIndexerBase : public VolumeIndexerData
int iDataBlockDim = 0;
for (int iDimension = 0; iDimension < Dimensionality_Max; iDimension++)
{
newIndexer.voxelMin[iDimension] = anNewVoxelMin[iDimension];
newIndexer.voxelMax[iDimension] = anNewVoxelMax[iDimension];
newIndexer.pitch[iDimension] = pitch;
newIndexer.bitPitch[iDimension] = bitPitch;
newIndexer.isDimensionLODDecimated[iDimension] = true;
static_cast<VolumeIndexerData &>(newIndexer).voxelMin[iDimension] = anNewVoxelMin[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).voxelMax[iDimension] = anNewVoxelMax[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).pitch[iDimension] = pitch;
static_cast<VolumeIndexerData &>(newIndexer).bitPitch[iDimension] = bitPitch;
static_cast<VolumeIndexerData &>(newIndexer).isDimensionLODDecimated[iDimension] = true;
if (indexer.localChunkSamples[iDimension] == indexer.voxelMax[iDimension] - indexer.voxelMin[iDimension])
{
newIndexer.localChunkSamples[iDimension] = anNewVoxelMax[iDimension] - anNewVoxelMin[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension] = anNewVoxelMax[iDimension] - anNewVoxelMin[iDimension];
}
else
{
newIndexer.localChunkSamples[iDimension] = (anNewVoxelMax[iDimension] - anNewVoxelMin[iDimension] + (1 << newIndexer.lod) - 1) >> newIndexer.lod;
static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension] = (anNewVoxelMax[iDimension] - anNewVoxelMin[iDimension] + (1 << static_cast<VolumeIndexerData &>(newIndexer).lod) - 1) >> static_cast<VolumeIndexerData &>(newIndexer).lod;
}
newIndexer.localChunkAllocatedSize[iDimension] = newIndexer.localChunkSamples[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).localChunkAllocatedSize[iDimension] = static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension];
pitch *= newIndexer.localChunkSamples[iDimension];
pitch *= static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension];
bitPitch = pitch * 8;
if (newIndexer.localChunkSamples[iDimension] > 1)
if (static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension] > 1)
{
//Don't allow temp buffers with more than 4D data blocks
assert(iDataBlockDim < DataBlockDimensionality_Max);
// dimension has size, make sure it's mapped
newIndexer.dimensionMap[iDataBlockDim] = iDimension;
static_cast<VolumeIndexerData &>(newIndexer).dimensionMap[iDataBlockDim] = iDimension;
// check for LOD decimation, and copy that (Dimension Maps may be different, so don't use that)
if (newIndexer.localChunkSamples[iDimension] == newIndexer.voxelMax[iDimension] - newIndexer.voxelMin[iDimension])
if (static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension] == static_cast<VolumeIndexerData &>(newIndexer).voxelMax[iDimension] - static_cast<VolumeIndexerData &>(newIndexer).voxelMin[iDimension])
{
newIndexer.isDimensionLODDecimated[iDimension] = false;
static_cast<VolumeIndexerData &>(newIndexer).isDimensionLODDecimated[iDimension] = false;
}
newIndexer.dataBlockSamples[iDataBlockDim] = newIndexer.localChunkSamples[iDimension];
newIndexer.dataBlockAllocatedSize[iDataBlockDim] = newIndexer.localChunkSamples[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).dataBlockSamples[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension];
static_cast<VolumeIndexerData &>(newIndexer).dataBlockAllocatedSize[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).localChunkSamples[iDimension];
iDataBlockDim++;
}
......@@ -988,12 +998,12 @@ struct VolumeIndexerBase : public VolumeIndexerData
}
//set pitches
newIndexer.dataBlockPitch[0] = 1;
newIndexer.dataBlockBitPitch[0] = 1;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[0] = 1;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockBitPitch[0] = 1;
for (int iDataBlockDim = 1; iDataBlockDim < DataBlockDimensionality_Max; iDataBlockDim++)
{
newIndexer.dataBlockPitch[iDataBlockDim] = newIndexer.dataBlockPitch[iDataBlockDim - 1] * newIndexer.dataBlockSamples[iDataBlockDim - 1];
newIndexer.dataBlockBitPitch[iDataBlockDim] = newIndexer.dataBlockPitch[iDataBlockDim] * 8;
static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[iDataBlockDim - 1] * static_cast<VolumeIndexerData &>(newIndexer).dataBlockSamples[iDataBlockDim - 1];
static_cast<VolumeIndexerData &>(newIndexer).dataBlockBitPitch[iDataBlockDim] = static_cast<VolumeIndexerData &>(newIndexer).dataBlockPitch[iDataBlockDim] * 8;
}
return newIndexer;
......
......@@ -33,7 +33,7 @@ class Base64Table
{
memset(Table, -1, sizeof(Table));
for(int i = 0; i < sizeof(Alphabet) - 1; i++)
for(int i = 0; i < int(sizeof(Alphabet)) - 1; i++)
{
Table[int(Alphabet[i])] = i;
}
......@@ -63,26 +63,79 @@ bool Base64Decode(const char *data, int64_t len, std::vector<unsigned char> &res
result.reserve(result.size() + len / 4 * 3);
while(len != 0 && !isspace(*data))
while (len != 0 && !isspace(*data))
{
int a = Base64Table::Decode(*data++); len--; if(a == -1) { error = true; break; }
int a = Base64Table::Decode(*data++); len--;
if (a == -1)
{
error = true;
break;
}
if (len == 0 || isspace(*data))
{