Fixed some compiler warnings.

This commit is contained in:
David Williams 2015-03-21 07:40:32 +01:00
parent 69f6f4ac37
commit 0e995b5140
3 changed files with 12 additions and 4 deletions

View File

@ -37,6 +37,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") #Maybe "OR
ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode
ENDIF() ENDIF()
IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF()
ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(include)
OPTION(ENABLE_EXAMPLES "Should the examples be built" ON) OPTION(ENABLE_EXAMPLES "Should the examples be built" ON)

View File

@ -57,8 +57,8 @@ void createSphereInVolume(RawVolume<MaterialDensityPair88>& volData, float fRadi
void createCubeInVolume(RawVolume<MaterialDensityPair88>& volData, Vector3DInt32 lowerCorner, Vector3DInt32 upperCorner, uint8_t uValue) void createCubeInVolume(RawVolume<MaterialDensityPair88>& volData, Vector3DInt32 lowerCorner, Vector3DInt32 upperCorner, uint8_t uValue)
{ {
uint8_t maxDen = MaterialDensityPair88::getMaxDensity(); uint8_t maxDen = static_cast<uint8_t>(MaterialDensityPair88::getMaxDensity());
uint8_t minDen = MaterialDensityPair88::getMinDensity(); uint8_t minDen = static_cast<uint8_t>(MaterialDensityPair88::getMinDensity());
//This three-level for loop iterates over every voxel between the specified corners //This three-level for loop iterates over every voxel between the specified corners
for (int z = lowerCorner.getZ(); z <= upperCorner.getZ(); z++) for (int z = lowerCorner.getZ(); z <= upperCorner.getZ(); z++)
{ {

View File

@ -73,7 +73,9 @@ public:
/// Gets a voxel at the position given by <tt>x,y,z</tt> coordinates /// Gets a voxel at the position given by <tt>x,y,z</tt> coordinates
VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const
{ {
if ((uXPos < mVolumeData.getDimension(0)) && (uYPos < mVolumeData.getDimension(1)) && (uZPos < mVolumeData.getDimension(2))) if ((uXPos >= 0) && (uXPos < static_cast<int32_t>(mVolumeData.getDimension(0))) &&
(uYPos >= 0) && (uYPos < static_cast<int32_t>(mVolumeData.getDimension(1))) &&
(uZPos >= 0) && (uZPos < static_cast<int32_t>(mVolumeData.getDimension(2))))
{ {
return mVolumeData(uXPos, uYPos, uZPos); return mVolumeData(uXPos, uYPos, uZPos);
} }
@ -94,7 +96,9 @@ public:
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates /// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
bool setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) bool setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue)
{ {
if ((uXPos < mVolumeData.getDimension(0)) && (uYPos < mVolumeData.getDimension(1)) && (uZPos < mVolumeData.getDimension(2))) if( (uXPos >= 0) && (uXPos < static_cast<int32_t>(mVolumeData.getDimension(0))) &&
(uYPos >= 0) && (uYPos < static_cast<int32_t>(mVolumeData.getDimension(1))) &&
(uZPos >= 0) && (uZPos < static_cast<int32_t>(mVolumeData.getDimension(2))))
{ {
mVolumeData(uXPos, uYPos, uZPos) = tValue; mVolumeData(uXPos, uYPos, uZPos) = tValue;
return true; return true;