Commit 1d009b00 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

fixed some warnings and bugs.

parent 9591e2c3
...@@ -164,7 +164,7 @@ namespace campvis { ...@@ -164,7 +164,7 @@ namespace campvis {
template<typename T, size_t ND> template<typename T, size_t ND>
void campvis::ConcurrentGenericHistogramND<T, ND>::addSample(T sample[ND]) { void campvis::ConcurrentGenericHistogramND<T, ND>::addSample(T sample[ND]) {
size_t bucketNumbers[ND]; size_t bucketNumbers[ND];
for(int i = 0; i < ND; ++i) for (size_t i = 0; i < ND; ++i)
bucketNumbers[i] = getBucketNumber(i, sample[i]); bucketNumbers[i] = getBucketNumber(i, sample[i]);
size_t index = getArrayIndex(bucketNumbers); size_t index = getArrayIndex(bucketNumbers);
...@@ -186,13 +186,10 @@ namespace campvis { ...@@ -186,13 +186,10 @@ namespace campvis {
if (sample < _min[dimension] || sample > _max[dimension]) { if (sample < _min[dimension] || sample > _max[dimension]) {
return _numBuckets[dimension]; return _numBuckets[dimension];
#ifdef CAMPVIS_DEBUG_NOTNOW
LWARNINGC("CAMPVis.core.tools.ConcurrentGenericHistogramND", "Added sample " << sample << " out of bounds for dimension " << dimension << ".");
#endif
} }
double ratio = static_cast<double>(sample - _min[dimension]) / static_cast<double>(_max[dimension] - _min[dimension]); double ratio = static_cast<double>(sample - _min[dimension]) / static_cast<double>(_max[dimension] - _min[dimension]);
return static_cast<size_t>(tgt::clamp(static_cast<int>(ratio * _numBuckets[dimension]), static_cast<int>(0), static_cast<int>(_numBuckets[dimension] - 1))); return static_cast<size_t>(tgt::clamp(static_cast<int>(ratio * _numBuckets[dimension]), static_cast<int>(0), static_cast<int>(_numBuckets[dimension]) - 1));
} }
template<typename T, size_t ND> template<typename T, size_t ND>
......
...@@ -120,21 +120,21 @@ namespace campvis { ...@@ -120,21 +120,21 @@ namespace campvis {
LDEBUG("pixel type: " << imageIO->GetPixelType()); // '5' LDEBUG("pixel type: " << imageIO->GetPixelType()); // '5'
switch (pixelType) { switch (pixelType) {
case ScalarPixelType::CHAR: case itk::ImageIOBase::CHAR:
wtp._baseType = WeaklyTypedPointer::INT8; break; wtp._baseType = WeaklyTypedPointer::INT8; break;
case ScalarPixelType::UCHAR: case itk::ImageIOBase::UCHAR:
wtp._baseType = WeaklyTypedPointer::UINT8; break; wtp._baseType = WeaklyTypedPointer::UINT8; break;
case ScalarPixelType::SHORT: case itk::ImageIOBase::SHORT:
wtp._baseType = WeaklyTypedPointer::INT16; break; wtp._baseType = WeaklyTypedPointer::INT16; break;
case ScalarPixelType::USHORT: case itk::ImageIOBase::USHORT:
wtp._baseType = WeaklyTypedPointer::UINT16; break; wtp._baseType = WeaklyTypedPointer::UINT16; break;
case ScalarPixelType::INT: case itk::ImageIOBase::INT:
wtp._baseType = WeaklyTypedPointer::INT32; break; wtp._baseType = WeaklyTypedPointer::INT32; break;
case ScalarPixelType::UINT: case itk::ImageIOBase::UINT:
wtp._baseType = WeaklyTypedPointer::UINT32; break; wtp._baseType = WeaklyTypedPointer::UINT32; break;
case ScalarPixelType::DOUBLE: case itk::ImageIOBase::DOUBLE:
LWARNING("Pixel Type is DOUBLE. Conversion to float may result in loss of precision!"); LWARNING("Pixel Type is DOUBLE. Conversion to float may result in loss of precision!");
case ScalarPixelType::FLOAT: case itk::ImageIOBase::FLOAT:
wtp._baseType = WeaklyTypedPointer::FLOAT; break; wtp._baseType = WeaklyTypedPointer::FLOAT; break;
...@@ -150,7 +150,7 @@ namespace campvis { ...@@ -150,7 +150,7 @@ namespace campvis {
ioRegion.SetSize(ioSize); ioRegion.SetSize(ioSize);
imageIO->SetIORegion(ioRegion); imageIO->SetIORegion(ioRegion);
if (pixelType != ScalarPixelType::DOUBLE) { if (pixelType != itk::ImageIOBase::DOUBLE) {
//Finally, allocate buffer and read the image data //Finally, allocate buffer and read the image data
wtp._pointer = new uint8_t[imageIO->GetImageSizeInBytes()]; wtp._pointer = new uint8_t[imageIO->GetImageSizeInBytes()];
imageIO->Read(wtp._pointer); imageIO->Read(wtp._pointer);
...@@ -248,21 +248,21 @@ namespace campvis { ...@@ -248,21 +248,21 @@ namespace campvis {
LDEBUG("pixel type: " << imageIO->GetPixelType()); LDEBUG("pixel type: " << imageIO->GetPixelType());
switch (pixelType) { switch (pixelType) {
case ScalarPixelType::CHAR: case itk::ImageIOBase::CHAR:
wtp._baseType = WeaklyTypedPointer::INT8; break; wtp._baseType = WeaklyTypedPointer::INT8; break;
case ScalarPixelType::UCHAR: case itk::ImageIOBase::UCHAR:
wtp._baseType = WeaklyTypedPointer::UINT8; break; wtp._baseType = WeaklyTypedPointer::UINT8; break;
case ScalarPixelType::SHORT: case itk::ImageIOBase::SHORT:
wtp._baseType = WeaklyTypedPointer::INT16; break; wtp._baseType = WeaklyTypedPointer::INT16; break;
case ScalarPixelType::USHORT: case itk::ImageIOBase::USHORT:
wtp._baseType = WeaklyTypedPointer::UINT16; break; wtp._baseType = WeaklyTypedPointer::UINT16; break;
case ScalarPixelType::INT: case itk::ImageIOBase::INT:
wtp._baseType = WeaklyTypedPointer::INT32; break; wtp._baseType = WeaklyTypedPointer::INT32; break;
case ScalarPixelType::UINT: case itk::ImageIOBase::UINT:
wtp._baseType = WeaklyTypedPointer::UINT32; break; wtp._baseType = WeaklyTypedPointer::UINT32; break;
case ScalarPixelType::DOUBLE: case itk::ImageIOBase::DOUBLE:
LWARNING("Pixel Type is DOUBLE. Conversion to float may result in loss of precision!"); LWARNING("Pixel Type is DOUBLE. Conversion to float may result in loss of precision!");
case ScalarPixelType::FLOAT: case itk::ImageIOBase::FLOAT:
wtp._baseType = WeaklyTypedPointer::FLOAT; break; wtp._baseType = WeaklyTypedPointer::FLOAT; break;
...@@ -279,8 +279,8 @@ namespace campvis { ...@@ -279,8 +279,8 @@ namespace campvis {
imageIO->SetIORegion(ioRegion); imageIO->SetIORegion(ioRegion);
//allocate a temporary buffer if necessary //allocate a temporary buffer if necessary
double* inputBuf = (pixelType == ScalarPixelType::DOUBLE) ? new double[imageIO->GetImageSizeInComponents()] : nullptr; double* inputBuf = (pixelType == itk::ImageIOBase::DOUBLE) ? new double[imageIO->GetImageSizeInComponents()] : nullptr;
size_t sliceSize = (pixelType == ScalarPixelType::DOUBLE) ? imageIO->GetImageSizeInComponents() * sizeof(float) : imageIO->GetImageSizeInBytes(); size_t sliceSize = (pixelType == itk::ImageIOBase::DOUBLE) ? imageIO->GetImageSizeInComponents() * sizeof(float) : imageIO->GetImageSizeInBytes();
wtp._pointer = new uint8_t[numSlices * sliceSize]; wtp._pointer = new uint8_t[numSlices * sliceSize];
for (int idx = 0; idx < numSlices; ++idx) { for (int idx = 0; idx < numSlices; ++idx) {
itk::ImageIOBase::Pointer fileIO = imageIO; itk::ImageIOBase::Pointer fileIO = imageIO;
...@@ -289,7 +289,7 @@ namespace campvis { ...@@ -289,7 +289,7 @@ namespace campvis {
fileIO->ReadImageInformation(); fileIO->ReadImageInformation();
fileIO->SetIORegion(ioRegion); fileIO->SetIORegion(ioRegion);
size_t currentSliceSize = (pixelType == ScalarPixelType::DOUBLE) ? imageIO->GetImageSizeInComponents() * sizeof(float) : fileIO->GetImageSizeInBytes(); size_t currentSliceSize = (pixelType == itk::ImageIOBase::DOUBLE) ? imageIO->GetImageSizeInComponents() * sizeof(float) : fileIO->GetImageSizeInBytes();
if (currentSliceSize != sliceSize) { if (currentSliceSize != sliceSize) {
LERROR("Image " << imageFileNames[idx] << " has different dimensionality or data type!"); LERROR("Image " << imageFileNames[idx] << " has different dimensionality or data type!");
delete static_cast<uint8_t*>(wtp._pointer); delete static_cast<uint8_t*>(wtp._pointer);
...@@ -300,7 +300,7 @@ namespace campvis { ...@@ -300,7 +300,7 @@ namespace campvis {
uint8_t* sliceBuffer = static_cast<uint8_t*>(wtp._pointer) + idx * sliceSize; uint8_t* sliceBuffer = static_cast<uint8_t*>(wtp._pointer) + idx * sliceSize;
if (pixelType != ScalarPixelType::DOUBLE) { if (pixelType != itk::ImageIOBase::DOUBLE) {
// directly read slice into buffer // directly read slice into buffer
fileIO->Read(sliceBuffer); fileIO->Read(sliceBuffer);
} }
......
...@@ -93,7 +93,7 @@ namespace campvis { ...@@ -93,7 +93,7 @@ namespace campvis {
// Construct the clipping plane in world coordinates // Construct the clipping plane in world coordinates
tgt::vec3 n = tgt::normalize(p_planeNormal.getValue()); tgt::vec3 n = tgt::normalize(p_planeNormal.getValue());
tgt::vec3 temp(1.0, 0.0, 0.0); tgt::vec3 temp(1.0, 0.0, 0.0);
if (abs(tgt::dot(temp, n) > 0.9)) if (abs(tgt::dot(temp, n)) > 0.9)
temp = tgt::vec3(0.0, 1.0, 0.0); temp = tgt::vec3(0.0, 1.0, 0.0);
tgt::vec3 inPlaneA = tgt::normalize(tgt::cross(n, temp)) * 0.5f * p_planeSize.getValue(); tgt::vec3 inPlaneA = tgt::normalize(tgt::cross(n, temp)) * 0.5f * p_planeSize.getValue();
......
...@@ -74,7 +74,7 @@ namespace campvis { ...@@ -74,7 +74,7 @@ namespace campvis {
std::vector<tgt::vec3> vertices; std::vector<tgt::vec3> vertices;
tgt::vec3 temp = cam.getUpVector(); tgt::vec3 temp = cam.getUpVector();
if(abs(tgt::dot(temp, n) > 0.9f)) if (abs(tgt::dot(temp, n)) > 0.9f)
temp = tgt::vec3(0.f, 1.f, 0.f); temp = tgt::vec3(0.f, 1.f, 0.f);
tgt::vec3 inPlaneA = tgt::normalize(tgt::cross(n, temp)) * 0.5f * p_size.getValue(); tgt::vec3 inPlaneA = tgt::normalize(tgt::cross(n, temp)) * 0.5f * p_size.getValue();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment