Commit 43ed4020 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Trying to fix linking-related issue when building both OpenIGTLink module and scripting feature.

Fixed various GCC and Cppcheck warnings.
parent 84a914e7
...@@ -280,11 +280,10 @@ namespace campvis { ...@@ -280,11 +280,10 @@ namespace campvis {
tgt::mat4 MatrixProcessor::processModifierString(tgt::mat4 matrix, std::string modifiers) tgt::mat4 MatrixProcessor::processModifierString(tgt::mat4 matrix, std::string modifiers)
{ {
int pos = 0; size_t pos = 0;
tgt::mat4 result = matrix, tmp; tgt::mat4 result = matrix, tmp;
while (pos < modifiers.size()) while (pos < modifiers.size()) {
{
switch (modifiers[pos]) { switch (modifiers[pos]) {
case 'I': case 'I':
if (!result.invert(tmp)) { if (!result.invert(tmp)) {
......
...@@ -341,9 +341,7 @@ namespace campvis { ...@@ -341,9 +341,7 @@ namespace campvis {
float spacing[3]; // spacing (mm/pixel) float spacing[3]; // spacing (mm/pixel)
int svsize[3]; // sub-volume size int svsize[3]; // sub-volume size
int svoffset[3]; // sub-volume offset int svoffset[3]; // sub-volume offset
int scalarType; // scalar type
scalarType = imgMsg->GetScalarType();
imgMsg->GetDimensions(size); imgMsg->GetDimensions(size);
imgMsg->GetSpacing(spacing); imgMsg->GetSpacing(spacing);
imgMsg->GetSubVolume(svsize, svoffset); imgMsg->GetSubVolume(svsize, svoffset);
......
...@@ -69,6 +69,7 @@ MACRO(DECLARE_LUA_MODULE InterfaceFile) ...@@ -69,6 +69,7 @@ MACRO(DECLARE_LUA_MODULE InterfaceFile)
SET_SOURCE_FILES_PROPERTIES(${InterfaceFile} PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(${InterfaceFile} PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(${InterfaceFile} PROPERTIES SWIG_FLAGS "-I${CampvisHome}") SET_SOURCE_FILES_PROPERTIES(${InterfaceFile} PROPERTIES SWIG_FLAGS "-I${CampvisHome}")
LINK_DIRECTORIES(${CampvisGlobalLinkDirectories} ${CampvisModulesLinkDirectories})
SWIG_ADD_MODULE(${LuaModName} lua ${InterfaceFile}) SWIG_ADD_MODULE(${LuaModName} lua ${InterfaceFile})
SWIG_LINK_LIBRARIES(${LuaModName} tgt campvis-core campvis-modules ${CampvisGlobalExternalLibs}) SWIG_LINK_LIBRARIES(${LuaModName} tgt campvis-core campvis-modules ${CampvisGlobalExternalLibs})
...@@ -119,6 +120,7 @@ LIST(APPEND CampvisScriptingHeaders "swigluarun.h") ...@@ -119,6 +120,7 @@ LIST(APPEND CampvisScriptingHeaders "swigluarun.h")
ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CampvisScriptingDefinitions}) ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CampvisScriptingDefinitions})
INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CMAKE_CURRENT_BINARY_DIR}) INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CMAKE_CURRENT_BINARY_DIR})
LINK_DIRECTORIES(${CampvisGlobalLinkDirectories} ${CampvisModulesLinkDirectories})
ADD_LIBRARY(campvis-scripting STATIC ADD_LIBRARY(campvis-scripting STATIC
${CampvisScriptingSources} ${CampvisScriptingHeaders} ${CampvisScriptingSources} ${CampvisScriptingHeaders}
......
// ================================================================================================ // ================================================================================================
// //
// This file is part of the CAMPVis Software Framework. // This file is part of the CAMPVis Software Framework.
// //
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved, // If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de> // Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures // Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen // Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany // Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
// //
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt". // For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// //
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at // except in compliance with the License. You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software distributed under the // Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions // either express or implied. See the License for the specific language governing permissions
// and limitations under the License. // and limitations under the License.
// //
// ================================================================================================ // ================================================================================================
/** /**
* Author: Hossain Mahmud <mahmud@in.tum.de> * Author: Hossain Mahmud <mahmud@in.tum.de>
* Date: March 2014 * Date: March 2014
*/ */
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "core/datastructures/datacontainer.h" #include "core/datastructures/datacontainer.h"
#include "core/datastructures/datahandle.h" #include "core/datastructures/datahandle.h"
#include "core/datastructures/imagedata.h" #include "core/datastructures/imagedata.h"
using namespace campvis; using namespace campvis;
/** /**
* Test class for DataContainer class * Test class for DataContainer class
*/ */
class DataContainerTest : public ::testing::Test { class DataContainerTest : public ::testing::Test {
protected: protected:
DataContainerTest() { DataContainerTest() {
this->_data = new ImageData(2, tgt::svec3(1,2,1), 4); this->_data = new ImageData(2, tgt::svec3(1,2,1), 4);
this->_dc0 = new DataContainer("dc0"); this->_dc0 = new DataContainer("dc0");
} }
~DataContainerTest() { ~DataContainerTest() {
delete this->_dc0; delete this->_dc0;
} }
virtual void SetUp() { virtual void SetUp() {
} }
virtual void TearDown() { virtual void TearDown() {
} }
protected: protected:
DataContainer *_dc0; DataContainer *_dc0;
AbstractData * _data; AbstractData * _data;
}; };
/** /**
* Tests the trivial operations of the class. * Tests the trivial operations of the class.
* getName() * getName()
* addData() * addData()
* addDataHandle() * addDataHandle()
* getData() * getData()
* hasData() * hasData()
* removeData() * removeData()
*/ */
TEST_F(DataContainerTest, miscellaneousTest) { TEST_F(DataContainerTest, miscellaneousTest) {
EXPECT_EQ("dc0", this->_dc0->getName()); EXPECT_EQ("dc0", this->_dc0->getName());
EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData()); EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData());
this->_dc0->addData("data1", this->_data); this->_dc0->addData("data1", this->_data);
EXPECT_EQ(this->_data, this->_dc0->getData("data1").getData()); EXPECT_EQ(this->_data, this->_dc0->getData("data1").getData());
this->_dc0->addDataHandle("data2", DataHandle(this->_data)); this->_dc0->addDataHandle("data2", DataHandle(this->_data));
this->_dc0->removeData("data1"); this->_dc0->removeData("data1");
EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData()); EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData());
EXPECT_FALSE(this->_dc0->hasData("data1")); EXPECT_FALSE(this->_dc0->hasData("data1"));
EXPECT_TRUE(this->_dc0->hasData("data2")); EXPECT_TRUE(this->_dc0->hasData("data2"));
} }
/** /**
* Tests the function getDataHandlesCopy. * Tests the function getDataHandlesCopy.
*/ */
TEST_F(DataContainerTest, getDataHandlesCopyTest) { TEST_F(DataContainerTest, getDataHandlesCopyTest) {
EXPECT_EQ(0, this->_dc0->getDataHandlesCopy().size()); EXPECT_EQ(0U, this->_dc0->getDataHandlesCopy().size());
this->_dc0->addData("data1", this->_data); this->_dc0->addData("data1", this->_data);
EXPECT_EQ(1, this->_dc0->getDataHandlesCopy().size()); EXPECT_EQ(1U, this->_dc0->getDataHandlesCopy().size());
std::pair<std::string, DataHandle> pair = this->_dc0->getDataHandlesCopy()[0]; std::pair<std::string, DataHandle> pair = this->_dc0->getDataHandlesCopy()[0];
EXPECT_EQ("data1", pair.first); EXPECT_EQ("data1", pair.first);
EXPECT_EQ(this->_data, pair.second.getData()); EXPECT_EQ(this->_data, pair.second.getData());
} }
/** /**
* Tests the concurrent access settings of the class. * Tests the concurrent access settings of the class.
* *
* DataHandle of previously added data obtained with getData() should remains valid * DataHandle of previously added data obtained with getData() should remains valid
* even if the data in the container is replaced with new data. * even if the data in the container is replaced with new data.
*/ */
TEST_F(DataContainerTest, concurrentAccessTest) { TEST_F(DataContainerTest, concurrentAccessTest) {
this->_dc0->addData("data1", this->_data); this->_dc0->addData("data1", this->_data);
DataHandle dh = this->_dc0->getData("data1"); DataHandle dh = this->_dc0->getData("data1");
AbstractData *someData = new ImageData(2, tgt::svec3(1,2,1), 4); AbstractData *someData = new ImageData(2, tgt::svec3(1,2,1), 4);
this->_dc0->addData("data1", someData); this->_dc0->addData("data1", someData);
EXPECT_EQ(someData, this->_dc0->getData("data1").getData()); EXPECT_EQ(someData, this->_dc0->getData("data1").getData());
EXPECT_NE(_data, this->_dc0->getData("data1").getData()); EXPECT_NE(_data, this->_dc0->getData("data1").getData());
EXPECT_EQ(_data, dh.getData()); EXPECT_EQ(_data, dh.getData());
} }
// ================================================================================================ // ================================================================================================
// //
// This file is part of the CAMPVis Software Framework. // This file is part of the CAMPVis Software Framework.
// //
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved, // If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de> // Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures // Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen // Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany // Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
// //
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt". // For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// //
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at // except in compliance with the License. You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software distributed under the // Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions // either express or implied. See the License for the specific language governing permissions
// and limitations under the License. // and limitations under the License.
// //
// ================================================================================================ // ================================================================================================
/** /**
* Author: Hossain Mahmud <mahmud@in.tum.de> * Author: Hossain Mahmud <mahmud@in.tum.de>
* Date: March 2014 * Date: March 2014
*/ */
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "core/datastructures/imagedata.h" #include "core/datastructures/imagedata.h"
#include "core/datastructures/imagedata.h" #include "core/datastructures/imagedata.h"
/** /**
* Test class for ImageData class. * Test class for ImageData class.
*/ */
class ImageDataTest : public testing::Test { class ImageDataTest : public testing::Test {
protected: protected:
ImageDataTest() ImageDataTest()
: _size(3, 2, 1) : _size(3, 2, 1)
{ {
_imgData0 = new campvis::ImageData(2, _size, 4); _imgData0 = new campvis::ImageData(2, _size, 4);
_imgData1 = _imgData0->clone(); _imgData1 = _imgData0->clone();
_absData1 = _imgData1; _absData1 = _imgData1;
} }
~ImageDataTest() { ~ImageDataTest() {
delete _imgData0; delete _imgData0;
delete _imgData1; delete _imgData1;
} }
// If the constructor and destructor are not enough for setting up // If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following two methods // and cleaning up each test, you can define the following two methods
virtual void SetUp() { virtual void SetUp() {
} }
virtual void TearDown() { virtual void TearDown() {
} }
protected: protected:
campvis::ImageData *_imgData0, *_imgData1; campvis::ImageData *_imgData0, *_imgData1;
campvis::AbstractData * _absData1; campvis::AbstractData * _absData1;
tgt::svec3 _size; tgt::svec3 _size;
}; };
/** /**
* Tests the trivial operations of the class. * Tests the trivial operations of the class.
* initialization * initialization
* getDimensionality() * getDimensionality()
* getNumChannels() * getNumChannels()
* getNumElements() * getNumElements()
* getWorldBounds() * getWorldBounds()
* get/setMappingInformation() * get/setMappingInformation()
* positionToIndex()/indexToPosition() * positionToIndex()/indexToPosition()
*/ */
TEST_F(ImageDataTest, miscellaneousTest) { TEST_F(ImageDataTest, miscellaneousTest) {
ASSERT_TRUE(nullptr != _imgData1); ASSERT_TRUE(nullptr != _imgData1);
EXPECT_EQ(2, _imgData0->getDimensionality()); EXPECT_EQ(2U, _imgData0->getDimensionality());
EXPECT_EQ(4, _imgData0->getNumChannels()); EXPECT_EQ(4U, _imgData0->getNumChannels());
EXPECT_EQ(tgt::hmul(_size), _imgData0->getNumElements()); EXPECT_EQ(tgt::hmul(_size), _imgData0->getNumElements());
tgt::Bounds bound0 = _imgData0->getWorldBounds(); tgt::Bounds bound0 = _imgData0->getWorldBounds();
tgt::Bounds bound1 = _imgData1->getWorldBounds(); tgt::Bounds bound1 = _imgData1->getWorldBounds();
EXPECT_EQ(bound0, bound1); EXPECT_EQ(bound0, bound1);
campvis::ImageData temp = campvis::ImageData(3, tgt::svec3(3,2,1), 5); campvis::ImageData temp = campvis::ImageData(3, tgt::svec3(3,2,1), 5);
temp.setMappingInformation(_imgData0->getMappingInformation()); temp.setMappingInformation(_imgData0->getMappingInformation());
EXPECT_TRUE(temp.getMappingInformation() == _imgData0->getMappingInformation()); EXPECT_TRUE(temp.getMappingInformation() == _imgData0->getMappingInformation());
for (size_t i = 0; i < _imgData0->getNumElements(); ++i) { for (size_t i = 0; i < _imgData0->getNumElements(); ++i) {
tgt::svec3 position = _imgData0->indexToPosition(i); tgt::svec3 position = _imgData0->indexToPosition(i);
EXPECT_EQ(_imgData0->positionToIndex(position), i); EXPECT_EQ(_imgData0->positionToIndex(position), i);
} }
} }
/** /**
* Tests the clone() function. * Tests the clone() function.
*/ */
// TODO: extend the test for proper ImageData cloning // TODO: extend the test for proper ImageData cloning
TEST_F(ImageDataTest, cloneTest) { TEST_F(ImageDataTest, cloneTest) {
ASSERT_TRUE(nullptr != _imgData1); ASSERT_TRUE(nullptr != _imgData1);
EXPECT_EQ(_imgData0->getDimensionality(), _imgData1->getDimensionality()); EXPECT_EQ(_imgData0->getDimensionality(), _imgData1->getDimensionality());
EXPECT_EQ(_imgData0->getLocalMemoryFootprint(), _imgData1->getLocalMemoryFootprint()); EXPECT_EQ(_imgData0->getLocalMemoryFootprint(), _imgData1->getLocalMemoryFootprint());
EXPECT_TRUE(_imgData0->getMappingInformation() == _imgData1->getMappingInformation()); EXPECT_TRUE(_imgData0->getMappingInformation() == _imgData1->getMappingInformation());
EXPECT_EQ(_imgData0->getNumChannels(), _imgData1->getNumChannels()); EXPECT_EQ(_imgData0->getNumChannels(), _imgData1->getNumChannels());
EXPECT_EQ(_imgData0->getNumElements(), _imgData1->getNumElements()); EXPECT_EQ(_imgData0->getNumElements(), _imgData1->getNumElements());
//EXPECT_EQ(_imgData0->getRepresentation(), _imgData1->getRepresentation()); //EXPECT_EQ(_imgData0->getRepresentation(), _imgData1->getRepresentation());
EXPECT_EQ(_imgData0->getSize(), _imgData1->getSize()); EXPECT_EQ(_imgData0->getSize(), _imgData1->getSize());
//EXPECT_EQ(_imgData0->getSubImage(), _imgData1->getSubImage()); //EXPECT_EQ(_imgData0->getSubImage(), _imgData1->getSubImage());
EXPECT_EQ(_imgData0->getVideoMemoryFootprint(), _imgData1->getVideoMemoryFootprint()); EXPECT_EQ(_imgData0->getVideoMemoryFootprint(), _imgData1->getVideoMemoryFootprint());
} }
// ================================================================================================ // ================================================================================================
// //
// This file is part of the CAMPVis Software Framework. // This file is part of the CAMPVis Software Framework.
// //
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved, // If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de> // Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures // Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen // Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany // Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
// //
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt". // For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// //
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at // except in compliance with the License. You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software distributed under the // Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions // either express or implied. See the License for the specific language governing permissions
// and limitations under the License. // and limitations under the License.
// //
// ================================================================================================ // ================================================================================================
/** /**
* Author: Hossain Mahmud <mahmud@in.tum.de> * Author: Hossain Mahmud <mahmud@in.tum.de>
* Date: March 2014 * Date: March 2014
*/ */
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "core/datastructures/imageseries.h" #include "core/datastructures/imageseries.h"
#include "core/datastructures/imagedata.h" #include "core/datastructures/imagedata.h"
/** /**
* Test class for ImageSeries class. * Test class for ImageSeries class.
*/ */
class ImageSeriesTest : public testing::Test { class ImageSeriesTest : public testing::Test {
protected: protected:
ImageSeriesTest() { ImageSeriesTest() {
_image = new campvis::ImageData(2, tgt::svec3(1,2,1), 4); _image = new campvis::ImageData(2, tgt::svec3(1,2,1), 4);
_dh = campvis::DataHandle(_image); _dh = campvis::DataHandle(_image);
_imgSeries2.addImage(_image); _imgSeries2.addImage(_image);
_imgSeries3.addImage(_dh); _imgSeries3.addImage(_dh);
} }
~ImageSeriesTest() { ~ImageSeriesTest() {
} }
virtual void SetUp() { virtual void SetUp() {
} }
virtual void TearDown() { virtual void TearDown() {
} }
protected: protected:
campvis::ImageSeries _imgSeries1, _imgSeries2, _imgSeries3; campvis::ImageSeries _imgSeries1, _imgSeries2, _imgSeries3;