Skip to content
Snippets Groups Projects
Commit c4d8de6e authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Global option BORNAGAIN_TIFF_SUPPORT in cmake machinery was added.

parent 8491c85b
No related branches found
No related tags found
No related merge requests found
Showing
with 113 additions and 33 deletions
......@@ -20,6 +20,7 @@ option(BORNAGAIN_APPLE_BUNDLE "Create a Mac OS X bundle" OFF)
option(BORNAGAIN_OPENMPI "Build with OpenMPI support" OFF)
option(BORNAGAIN_RELEASE "Special option for making release" OFF)
option(BORNAGAIN_CRASHHADLER "Additional machinery to send crash reports" OFF)
option(BORNAGAIN_TIFF_SUPPORT "Tiff files read/write support" ON)
#--- Including macros ---
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
......@@ -36,14 +37,9 @@ if(BORNAGAIN_MANPAGE)
add_subdirectory(man)
endif()
if(NOT TIFF_FOUND)
add_subdirectory(ThirdParty/libtiff)
endif()
add_subdirectory(ThirdParty)
add_subdirectory(Core)
add_subdirectory(ThirdParty/gtest)
add_subdirectory(Tests/UnitTests/TestCore)
add_subdirectory(ThirdParty/RootMinimizers)
add_subdirectory(Fit)
add_subdirectory(Tests/UnitTests/TestFit)
......
......@@ -66,6 +66,9 @@ if(BORNAGAIN_OPENMPI)
add_definitions(-DBORNAGAIN_OPENMPI)
endif()
if(BORNAGAIN_TIFF_SUPPORT)
add_definitions(-DBORNAGAIN_TIFF_SUPPORT)
endif()
# --- making library ---------
add_library(
......@@ -96,8 +99,6 @@ target_link_libraries(
${TIFF_LIBRARIES}
)
message(INFO "XXX lib ${TIFF_LIBRARIES} include ${TIFF_INCLUDE_DIR}")
if(BORNAGAIN_OPENMPI)
include_directories(${MPI_INCLUDE_PATH})
target_link_libraries(${library_name} ${MPI_LIBRARIES})
......
......@@ -36,10 +36,13 @@ IOutputDataReadStrategy *OutputDataReadFactory::getReadStrategy(const std::strin
result = new OutputDataReadINTStrategy();
}
#ifdef BORNAGAIN_TIFF_SUPPORT
else if(OutputDataIOHelper::isTiffFile(file_name)) {
result = new OutputDataReadTiffStrategy();
}
#endif // BORNAGAIN_TIFF_SUPPORT
else {
throw LogicErrorException("OutputDataReadFactory::getReader() -> Error. "
"Don't know how to read file '" + file_name+std::string("'"));
......
......@@ -47,6 +47,7 @@ OutputData<double > *OutputDataReadINTStrategy::readOutputData(std::istream &inp
// ----------------------------------------------------------------------------
#ifdef BORNAGAIN_TIFF_SUPPORT
OutputDataReadTiffStrategy::OutputDataReadTiffStrategy()
: m_d(new TiffHandler)
{
......@@ -63,3 +64,5 @@ OutputData<double> *OutputDataReadTiffStrategy::readOutputData(std::istream &inp
m_d->read(input_stream);
return m_d->getOutputData()->clone();
}
#endif // BORNAGAIN_TIFF_SUPPORT
......@@ -42,6 +42,7 @@ public:
OutputData<double > *readOutputData(std::istream& input_stream);
};
#ifdef BORNAGAIN_TIFF_SUPPORT
class TiffHandler;
......@@ -58,6 +59,7 @@ public:
private:
TiffHandler *m_d;
};
#endif // BORNAGAIN_TIFF_SUPPORT
#endif // OUTPUTDATAREADSTRATEGY_H
......
......@@ -33,9 +33,11 @@ IOutputDataWriteStrategy *OutputDataWriteFactory::getWriteStrategy(const std::st
result = new OutputDataWriteINTStrategy();
}
#ifdef BORNAGAIN_TIFF_SUPPORT
else if(OutputDataIOHelper::isTiffFile(file_name)) {
result = new OutputDataWriteTiffStrategy();
}
#endif // BORNAGAIN_TIFF_SUPPORT
else {
throw LogicErrorException("OutputDataWriteFactory::getWriter() -> Error. "
......
......@@ -53,7 +53,7 @@ void OutputDataWriteINTStrategy::writeOutputData(const OutputData<double> &data,
// ----------------------------------------------------------------------------
#ifdef BORNAGAIN_TIFF_SUPPORT
OutputDataWriteTiffStrategy::OutputDataWriteTiffStrategy()
: m_d(new TiffHandler)
......@@ -72,5 +72,6 @@ void OutputDataWriteTiffStrategy::writeOutputData(const OutputData<double> &data
m_d->write(data, output_stream);
}
#endif
......@@ -46,6 +46,8 @@ public:
virtual void writeOutputData(const OutputData<double> &data, std::ostream &output_stream);
};
#ifdef BORNAGAIN_TIFF_SUPPORT
class TiffHandler;
//! @class OutputDataWriteTiffStrategy
......@@ -61,6 +63,7 @@ private:
TiffHandler *m_d;
};
#endif // BORNAGAIN_TIFF_SUPPORT
#endif // OUTPUTDATAWRITESTRATEGY_H
......
......@@ -12,6 +12,7 @@
//! @authors C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke
//
// ************************************************************************** //
#ifdef BORNAGAIN_TIFF_SUPPORT
#include "TiffHandler.h"
#include "Exceptions.h"
#include "Utils.h"
......@@ -209,5 +210,4 @@ void TiffHandler::create_output_data()
m_data->addAxis("y", m_height, 0.0, double(m_height));
}
#endif // BORNAGAIN_TIFF_SUPPORT
......@@ -16,6 +16,8 @@
#ifndef TIFFHANDLER_H
#define TIFFHANDLER_H
#ifdef BORNAGAIN_TIFF_SUPPORT
#include "WinDllMacros.h"
#include "OutputData.h"
#include <string>
......@@ -53,6 +55,7 @@ private:
boost::scoped_ptr<OutputData<double> > m_data;
};
#endif // BORNAGAIN_TIFF_SUPPORT
#endif
......@@ -54,6 +54,11 @@ set(list_of_python_tests
# "transform_BoxComposition.py" # broken, problems with absoprtion in FormFactorTruncatedSphere
)
if(BORNAGAIN_TIFF_SUPPORT)
list(APPEND list_of_python_tests "intensitydata_io_tiff.py")
endif()
foreach(_test ${list_of_python_tests})
add_test(${_test} ${PYTHON_EXECUTABLE} "${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyCore/${_test}")
endforeach()
......
......@@ -148,24 +148,5 @@ class OutputDataIOTest(unittest.TestCase):
newdata = IntensityDataIOFactory.readOutputData("tmp.int.bz2")
self.assertTrue(is_the_same_data(data, newdata))
def test_SaveToTiff(self):
data = IntensityData()
data.addAxis(FixedBinAxis("x", 10, 0.0, 10.0))
data.addAxis(FixedBinAxis("y", 5, 0.0, 5.0))
fill_data(data)
IntensityDataIOFactory.writeOutputData(data, "tmp.tif")
newdata = IntensityDataIOFactory.readOutputData("tmp.tif")
self.assertTrue(is_the_same_data(data, newdata))
IntensityDataIOFactory.writeOutputData(data, "tmp.tif.gz")
newdata = IntensityDataIOFactory.readOutputData("tmp.tif.gz")
self.assertTrue(is_the_same_data(data, newdata))
IntensityDataIOFactory.writeOutputData(data, "tmp.tif.bz2")
newdata = IntensityDataIOFactory.readOutputData("tmp.tif.bz2")
self.assertTrue(is_the_same_data(data, newdata))
if __name__ == '__main__':
unittest.main()
# Functional test: tests of IO operations with the IntensityData object
import sys
import os
import unittest
import numpy
import math
import time
sys.path.append(os.path.abspath(
os.path.join(os.path.split(__file__)[0],
'..', '..', '..', 'lib')))
from libBornAgainCore import *
def fill_data(data):
"""
Fills intensity data with some numbers
"""
for i in range(0, data.getAllocatedSize()):
data[i] = i
def is_the_same_data(data1, data2):
"""
Checks if two data are identical
"""
if data1.getAllocatedSize() != data2.getAllocatedSize():
return False
if data1.getRank() != data2.getRank():
return False
for i in range(0, data1.getRank()):
if data1.getAxis(i) != data2.getAxis(i):
return False
for i in range(0, data1.getAllocatedSize()):
if data1[i] != data2[i]:
return False
return True
class OutputDataIOTiffTest(unittest.TestCase):
"""
Test serialization of IntensityData into TIFF format
"""
def test_SaveToTiff(self):
data = IntensityData()
data.addAxis(FixedBinAxis("x", 10, 0.0, 10.0))
data.addAxis(FixedBinAxis("y", 5, 0.0, 5.0))
fill_data(data)
IntensityDataIOFactory.writeOutputData(data, "tmp.tif")
newdata = IntensityDataIOFactory.readOutputData("tmp.tif")
self.assertTrue(is_the_same_data(data, newdata))
IntensityDataIOFactory.writeOutputData(data, "tmp.tif.gz")
newdata = IntensityDataIOFactory.readOutputData("tmp.tif.gz")
self.assertTrue(is_the_same_data(data, newdata))
IntensityDataIOFactory.writeOutputData(data, "tmp.tif.bz2")
newdata = IntensityDataIOFactory.readOutputData("tmp.tif.bz2")
self.assertTrue(is_the_same_data(data, newdata))
if __name__ == '__main__':
unittest.main()
# Compilation of ThirdParty dependencies
if(BORNAGAIN_TIFF_SUPPORT)
if(NOT TIFF_FOUND)
add_subdirectory(libtiff)
endif()
endif()
add_subdirectory(gtest)
add_subdirectory(RootMinimizers)
......@@ -34,8 +34,8 @@ add_library(
STATIC
${source_files} ${include_files}
)
set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE)
set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE)
set(${library_name}_INCLUDE_DIRS ${include_dirs} CACHE INTERNAL "")
set(${library_name}_LIBRARY ${library_name} CACHE INTERNAL "")
# --- external dependencies ---
include_directories(${GSL_INCLUDE_DIR})
......
......@@ -39,7 +39,8 @@ find_package(GSL REQUIRED)
# -----------------------------------------------------------------------------
# Tiff
# -----------------------------------------------------------------------------
#find_package(TIFF)
if(BORNAGAIN_TIFF_SUPPORT)
find_package(TIFF)
# check if tiff setup contains C++ version of library too
# i.e. TIFF_LIBRARIES should be /usr/lib64/libtiff.so;/usr/lib64/libtiffxx.so
......@@ -68,6 +69,8 @@ if(TIFF_FOUND)
else()
message(STATUS "No TIFF library found, local version will be build.")
endif()
endif()
# --- Python ---
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment