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