diff --git a/CMake/PackageDepends/MITK_tinyxml2_Config.cmake b/CMake/PackageDepends/MITK_tinyxml2_Config.cmake
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/CMake/PackageDepends/MITK_tinyxml_Config.cmake b/CMake/PackageDepends/MITK_tinyxml_Config.cmake
deleted file mode 100644
index ee84a8ae1a..0000000000
--- a/CMake/PackageDepends/MITK_tinyxml_Config.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-list(APPEND ALL_LIBRARIES ${tinyxml_LIBRARIES})
-if(tinyxml_INCLUDE_DIRS)
- list(APPEND ALL_INCLUDE_DIRECTORIES ${tinyxml_INCLUDE_DIRS})
-endif()
diff --git a/CMakeExternals/ExternalProjectList.cmake b/CMakeExternals/ExternalProjectList.cmake
index ab452fc867..6305e62d20 100644
--- a/CMakeExternals/ExternalProjectList.cmake
+++ b/CMakeExternals/ExternalProjectList.cmake
@@ -1,26 +1,26 @@
mitkFunctionAddExternalProject(NAME Poco ON COMPONENTS Foundation Net Util XML Zip)
mitkFunctionAddExternalProject(NAME DCMTK ON DOC "EXPERIMENTAL, superbuild only: Use DCMTK in MITK")
mitkFunctionAddExternalProject(NAME OpenIGTLink OFF)
-mitkFunctionAddExternalProject(NAME tinyxml ON ADVANCED)
+mitkFunctionAddExternalProject(NAME tinyxml2 ON ADVANCED)
mitkFunctionAddExternalProject(NAME GDCM ON ADVANCED)
mitkFunctionAddExternalProject(NAME Eigen ON ADVANCED DOC "Use the Eigen library")
mitkFunctionAddExternalProject(NAME ANN ON ADVANCED DOC "Use Approximate Nearest Neighbor Library")
mitkFunctionAddExternalProject(NAME CppUnit ON ADVANCED DOC "Use CppUnit for unit tests")
mitkFunctionAddExternalProject(NAME PCRE OFF ADVANCED NO_PACKAGE)
mitkFunctionAddExternalProject(NAME HDF5 ON ADVANCED)
mitkFunctionAddExternalProject(NAME SWIG OFF ADVANCED NO_PACKAGE DEPENDS PCRE)
mitkFunctionAddExternalProject(NAME OpenCV OFF)
mitkFunctionAddExternalProject(NAME Vigra OFF DEPENDS HDF5)
mitkFunctionAddExternalProject(NAME ITK ON NO_CACHE DEPENDS HDF5)
mitkFunctionAddExternalProject(NAME VTK ON NO_CACHE)
mitkFunctionAddExternalProject(NAME Boost ON NO_CACHE)
mitkFunctionAddExternalProject(NAME ZLIB OFF ADVANCED)
mitkFunctionAddExternalProject(NAME cpprestsdk OFF DEPENDS Boost ZLIB ADVANCED)
mitkFunctionAddExternalProject(NAME OpenMesh OFF)
mitkFunctionAddExternalProject(NAME CTK ON DEPENDS Qt5 DCMTK DOC "Use CTK in MITK")
mitkFunctionAddExternalProject(NAME DCMQI ON DEPENDS DCMTK ITK DOC "Use dcmqi in MITK")
mitkFunctionAddExternalProject(NAME MatchPoint OFF ADVANCED DEPENDS ITK DOC "Use the MatchPoint translation image registration library")
if(MITK_USE_Qt5)
mitkFunctionAddExternalProject(NAME Qwt ON ADVANCED DEPENDS Qt5)
endif()
diff --git a/CMakeExternals/tinyxml-2.6.2.patch b/CMakeExternals/tinyxml-2.6.2.patch
deleted file mode 100644
index 4a601bb1e5..0000000000
--- a/CMakeExternals/tinyxml-2.6.2.patch
+++ /dev/null
@@ -1,266 +0,0 @@
-diff -burN tinyxml/tinyxml.cpp tinyxml-src/tinyxml.cpp
---- tinyxml/tinyxml.cpp 2011-05-15 04:24:57.000000000 +0200
-+++ tinyxml-src/tinyxml.cpp 2015-01-14 15:19:38.685333149 +0100
-@@ -34,6 +34,9 @@
- FILE* TiXmlFOpen( const char* filename, const char* mode );
-
- bool TiXmlBase::condenseWhiteSpace = true;
-+static unsigned int required_decimal_places = 14+1; // Need 14 for mitk default accuracy plus 1 to make sure we're within tolerance.
-+
-+
-
- // Microsoft compiler security
- FILE* TiXmlFOpen( const char* filename, const char* mode )
-@@ -757,21 +760,21 @@
- #endif
-
-
--void TiXmlElement::SetDoubleAttribute( const char * name, double val )
-+void TiXmlElement::SetDoubleAttribute( const char * name, double val, const unsigned int requiredDecimalPlaces )
- {
- TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
- if ( attrib ) {
-- attrib->SetDoubleValue( val );
-+ attrib->SetDoubleValue( val, requiredDecimalPlaces );
- }
- }
-
-
- #ifdef TIXML_USE_STL
--void TiXmlElement::SetDoubleAttribute( const std::string& name, double val )
-+void TiXmlElement::SetDoubleAttribute( const std::string& name, double val, const unsigned int requiredDecimalPlaces )
- {
- TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
- if ( attrib ) {
-- attrib->SetDoubleValue( val );
-+ attrib->SetDoubleValue( val, requiredDecimalPlaces );
- }
- }
- #endif
-@@ -1242,33 +1245,73 @@
-
- int TiXmlAttribute::QueryDoubleValue( double* dval ) const
- {
-+ //save old locale
-+ char * oldLocale;
-+ oldLocale = setlocale( LC_ALL, 0 );
-+
-+ //set new locale
-+ setlocale( LC_ALL, "C" );
- if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 )
-+ {
-+ //restore locale
-+ setlocale( LC_ALL, oldLocale );
- return TIXML_SUCCESS;
-+ }
-+ //restore locale
-+ setlocale( LC_ALL, oldLocale );
- return TIXML_WRONG_TYPE;
- }
-
- void TiXmlAttribute::SetIntValue( int _value )
- {
- char buf [64];
-- #if defined(TIXML_SNPRINTF)
-+#if defined(TIXML_SNPRINTF)
- TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value);
-- #else
-+#else
- sprintf (buf, "%d", _value);
-- #endif
-+#endif
- SetValue (buf);
- }
-
--void TiXmlAttribute::SetDoubleValue( double _value )
-+
-+
-+
-+void TiXmlAttribute::SetDoubleValue( double _value, const unsigned int requiredDecimalPlaces )
- {
-+#if defined(TIXML_USE_STL)
-+ std::ostringstream ss;
-+ //save old locale
-+ char * oldLocale;
-+ oldLocale = setlocale( LC_ALL, 0 );
-+
-+ //set new locale
-+ setlocale( LC_ALL, "C" );
-+ ss.precision(TiXmlBase::Precision(_value, requiredDecimalPlaces));
-+ ss << _value;
-+ SetValue( ss.str() );
-+ //restore locale
-+ setlocale( LC_ALL, oldLocale );
-+#else
- char buf [256];
-- #if defined(TIXML_SNPRINTF)
-- TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value);
-- #else
-- sprintf (buf, "%g", _value);
-- #endif
-+
-+ //save old locale
-+ char * oldLocale;
-+ oldLocale = setlocale( LC_ALL, 0 );
-+
-+ //set new locale
-+ setlocale( LC_ALL, "C" );
-+#if defined(TIXML_SNPRINTF)
-+ TIXML_SNPRINTF( buf, sizeof(buf), TiXmlBase::Format(_value, requiredDecimalPlaces).c_str(), _value);
-+#else
-+ sprintf (buf, TiXmlBase::Format(_value, requiredDecimalPlaces).c_str(), _value);
-+#endif
- SetValue (buf);
-+ //restore locale
-+ setlocale( LC_ALL, oldLocale );
-+#endif
- }
-
-+
- int TiXmlAttribute::IntValue() const
- {
- return atoi (value.c_str ());
-@@ -1276,7 +1319,15 @@
-
- double TiXmlAttribute::DoubleValue() const
- {
-+#if defined(TIXML_USE_STL)
-+ std::istringstream ss(value);
-+ ss.imbue(std::locale("C"));
-+ double dval;
-+ ss >> dval;
-+ return dval;
-+#else
- return atof (value.c_str ());
-+#endif
- }
-
-
-@@ -1884,3 +1935,36 @@
- return true;
- }
-
-+unsigned int TiXmlBase::Precision( const double value, const unsigned int requiredDecimalPlaces ) const
-+{
-+ unsigned int lhs = 0;
-+ unsigned int one_for_plus_minus_sign = 1;
-+
-+ lhs = 0;
-+ double temp(value);
-+ while (temp >= 1.0)
-+ {
-+ lhs++;
-+ temp /= 10.0;
-+ }
-+
-+ return( lhs + requiredDecimalPlaces + one_for_plus_minus_sign );
-+}
-+
-+/**
-+ Return the printf format string that will ensure that the double value
-+ passed in will be stored with 'required_decimal_places' worth of decimal
-+ points as well as enough digits for the left hand side of the decimal point.
-+ */
-+TIXML_STRING TiXmlBase::Format( const double value, const unsigned int requiredDecimalPlaces ) const
-+{
-+ char buf[ 32 ];
-+
-+#if defined(TIXML_SNPRINTF)
-+ TIXML_SNPRINTF( buf, sizeof(buf), "%%%d.%dlf", Precision(value, requiredDecimalPlaces), requiredDecimalPlaces);
-+#else
-+ sprintf( buf, "%%%d.%dlf", Precision(value, requiredDecimalPlaces), requiredDecimalPlaces);
-+#endif
-+
-+ return(TIXML_STRING(buf));
-+}
-diff -burN tinyxml/tinyxml.h tinyxml-src/tinyxml.h
---- tinyxml/tinyxml.h 2011-05-15 04:24:57.000000000 +0200
-+++ tinyxml-src/tinyxml.h 2015-01-14 15:19:38.686333149 +0100
-@@ -20,12 +20,24 @@
-
- 3. This notice may not be removed or altered from any source
- distribution.
--*/
-+ */
-
-
- #ifndef TINYXML_INCLUDED
- #define TINYXML_INCLUDED
-
-+#ifndef TIXML_USE_STL
-+ #define TIXML_USE_STL
-+#endif
-+
-+#ifndef TIXML_USE_STL
-+#define TIXML_USE_STL
-+#endif
-+
-+#ifndef TIXML_USE_STL
-+#define TIXML_USE_STL
-+#endif
-+
- #ifdef _MSC_VER
- #pragma warning( push )
- #pragma warning( disable : 4530 )
-@@ -93,9 +105,11 @@
- const int TIXML_MINOR_VERSION = 6;
- const int TIXML_PATCH_VERSION = 2;
-
-+#define DEFAULT_REQUIRED_DECIMAL_PLACES 14
-+
- /* Internal structure for tracking location of items
- in the XML file.
--*/
-+ */
- struct TiXmlCursor
- {
- TiXmlCursor() { Clear(); }
-@@ -283,6 +297,10 @@
- TIXML_ERROR_STRING_COUNT
- };
-
-+ unsigned int Precision( const double value, const unsigned int requiredDecimalPlaces ) const ;
-+
-+ TIXML_STRING Format( const double value, const unsigned int requiredDecimalPlaces ) const;
-+
- protected:
-
- static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
-@@ -836,14 +854,14 @@
- void SetValue( const char* _value ) { value = _value; } ///< Set the value.
-
- void SetIntValue( int _value ); ///< Set the value from an integer.
-- void SetDoubleValue( double _value ); ///< Set the value from a double.
-+ void SetDoubleValue( double _value, const unsigned int requiredDecimalPlaces = DEFAULT_REQUIRED_DECIMAL_PLACES ); ///< Set the value from a double.
-
-- #ifdef TIXML_USE_STL
-+#ifdef TIXML_USE_STL
- /// STL std::string form.
- void SetName( const std::string& _name ) { name = _name; }
- /// STL std::string form.
- void SetValue( const std::string& _value ) { value = _value; }
-- #endif
-+#endif
-
- /// Get the next sibling attribute in the DOM. Returns null at end.
- const TiXmlAttribute* Next() const;
-@@ -1061,8 +1079,8 @@
- ///< STL std::string form.
- void SetAttribute( const std::string& name, int _value );
- ///< STL std::string form.
-- void SetDoubleAttribute( const std::string& name, double value );
-- #endif
-+ void SetDoubleAttribute( const std::string& name, double value, const unsigned int requiredDecimalPlaces = DEFAULT_REQUIRED_DECIMAL_PLACES );
-+#endif
-
- /** Sets an attribute of name to a given value. The attribute
- will be created if it does not exist, or changed if it does.
-@@ -1072,7 +1090,7 @@
- /** Sets an attribute of name to a given value. The attribute
- will be created if it does not exist, or changed if it does.
- */
-- void SetDoubleAttribute( const char * name, double value );
-+ void SetDoubleAttribute( const char * name, double value, const unsigned int requiredDecimalPlaces = DEFAULT_REQUIRED_DECIMAL_PLACES );
-
- /** Deletes an attribute with the given name.
- */
diff --git a/CMakeExternals/tinyxml.cmake b/CMakeExternals/tinyxml2.cmake
similarity index 65%
rename from CMakeExternals/tinyxml.cmake
rename to CMakeExternals/tinyxml2.cmake
index 74391bee27..8b24f8c184 100644
--- a/CMakeExternals/tinyxml.cmake
+++ b/CMakeExternals/tinyxml2.cmake
@@ -1,52 +1,52 @@
#-----------------------------------------------------------------------------
-# tinyxml
+# tinyxml2
#-----------------------------------------------------------------------------
# Sanity checks
-if(DEFINED tinyxml_DIR AND NOT EXISTS ${tinyxml_DIR})
- message(FATAL_ERROR "tinyxml_DIR variable is defined but corresponds to non-existing directory")
+if(DEFINED tinyxml2_DIR AND NOT EXISTS ${tinyxml2_DIR})
+ message(FATAL_ERROR "tinyxml2_DIR variable is defined but corresponds to non-existing directory")
endif()
-set(proj tinyxml)
+set(proj tinyxml2)
set(proj_DEPENDENCIES )
set(${proj}_DEPENDS ${proj})
-if(NOT DEFINED tinyxml_DIR)
+if(NOT DEFINED tinyxml2_DIR)
set(additional_cmake_args )
if(WIN32)
set(additional_cmake_args -DBUILD_SHARED_LIBS:BOOL=OFF)
endif()
if(CTEST_USE_LAUNCHERS)
list(APPEND additional_cmake_args
"-DCMAKE_PROJECT_${proj}_INCLUDE:FILEPATH=${CMAKE_ROOT}/Modules/CTestUseLaunchers.cmake"
)
endif()
ExternalProject_Add(${proj}
LIST_SEPARATOR ${sep}
- URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/tinyxml_2_6_2.tar.gz
- URL_MD5 c1b864c96804a10526540c664ade67f0
- PATCH_COMMAND ${PATCH_COMMAND} -N -p1 -i ${CMAKE_CURRENT_LIST_DIR}/tinyxml-2.6.2.patch
- COMMAND ${CMAKE_COMMAND} -Dproj=${proj} -Dproj_target:STRING=tinyxml -P ${CMAKE_CURRENT_LIST_DIR}/GenerateDefaultCMakeBuildSystem.cmake
+ URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/tinyxml2-8.0.0.tar.gz
+ URL_MD5 5dc535c8b34ee621fe2128f072d275b5
CMAKE_GENERATOR ${gen}
CMAKE_GENERATOR_PLATFORM ${gen_platform}
CMAKE_ARGS
${ep_common_args}
${additional_cmake_args}
CMAKE_CACHE_ARGS
${ep_common_cache_args}
+ -DBUILD_TESTING:BOOL=OFF
+ -DBUILD_TESTS:BOOL=OFF
CMAKE_CACHE_DEFAULT_ARGS
${ep_common_cache_default_args}
DEPENDS ${proj_DEPENDENCIES}
)
set(${proj}_DIR ${ep_prefix})
mitkFunctionInstallExternalCMakeProject(${proj})
else()
mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}")
endif()
diff --git a/CMakeExternals/tinyxmlCMakeLists.txt b/CMakeExternals/tinyxmlCMakeLists.txt
deleted file mode 100644
index d19c0dfb25..0000000000
--- a/CMakeExternals/tinyxmlCMakeLists.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-cmake_minimum_required(VERSION 2.8.4)
-
-project(tinyxml)
-
-set(${PROJECT_NAME}_MAJOR_VERSION 2)
-set(${PROJECT_NAME}_MINOR_VERSION 6)
-set(${PROJECT_NAME}_PATCH_VERSION 2)
-set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION})
-
-
-set(tinyxml_HEADERS
- tinystr.h
- tinyxml.h
-)
-
-set(tinyxml_SOURCES
- tinyxml.cpp
- tinyxmlparser.cpp
- tinyxmlerror.cpp
- tinystr.cpp
-)
-
-add_library(tinyxml ${tinyxml_HEADERS} ${tinyxml_SOURCES})
-set_target_properties(tinyxml PROPERTIES
- SOVERSION ${${PROJECT_NAME}_VERSION})
-
-set(${PROJECT_NAME}_LIBRARIES tinyxml)
-
-# Install support
-
-install(TARGETS ${${PROJECT_NAME}_LIBRARIES} EXPORT ${PROJECT_NAME}_TARGETS
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
- RUNTIME DESTINATION bin
- INCLUDES DESTINATION include/${PROJECT_NAME}
-)
-install(FILES ${tinyxml_HEADERS}
- DESTINATION include/${PROJECT_NAME}
-)
-
-# Config files
-configure_file(
- ${PROJECT_NAME}Config.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
- @ONLY
-)
-configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}ConfigVersion.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
- @ONLY
-)
-
-export(EXPORT ${PROJECT_NAME}_TARGETS
- FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake
-)
-
-set(config_package_location lib/cmake/${PROJECT_NAME})
-install(EXPORT ${PROJECT_NAME}_TARGETS
- FILE ${PROJECT_NAME}Targets.cmake
- DESTINATION ${config_package_location}
-)
-install(FILES
- "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
- "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
- DESTINATION ${config_package_location}
-)
diff --git a/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox b/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox
index 5babea66ab..2b93804d69 100644
--- a/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox
+++ b/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox
@@ -1,107 +1,107 @@
/**
\page thirdpartylibs Third-party libraries
The following third-party libraries can be used with MITK by default and can, in part, be automatically downloaded during superbuild.
\par ANN
https://www.cs.umd.edu/~mount/ANN/
\par Boost
https://www.boost.org/
\par C++ REST SDK
https://github.com/Microsoft/cpprestsdk/
\par CppUnit
https://sourceforge.net/projects/cppunit/
\par CTK
https://commontk.org/
\par DCMTK
https://dicom.offis.de/dcmtk
\par Eigen
http://eigen.tuxfamily.org/index.php?title=Main_Page
\par GDCM
https://gdcm.sourceforge.net/
\par HDF5
https://support.hdfgroup.org/HDF5/
\par ITK
https://itk.org/
\par MatchPoint
https://www.dkfz.de/en/sidt/projects/MatchPoint/info.html
\par OpenCL
https://www.khronos.org/opencl/
\par OpenCV
https://opencv.org/
\par OpenIGTLink
http://openigtlink.org/
\par OpenMesh
https://www.openmesh.org/
\par PCRE
https://www.pcre.org/
\par POCO
https://pocoproject.org/
\par Python
https://www.python.org/
\par Qt
https://www.qt.io/
\par Qwt
http://qwt.sourceforge.net/
\par SWIG
http://www.swig.org/
-\par tinyxml
+\par TinyXML-2
-http://www.grinninglizard.com/tinyxml/
+http://www.grinninglizard.com/tinyxml2/
\par VIGRA
https://ukoethe.github.io/vigra/
\par VTK
https://vtk.org/
\par zlib
https://zlib.net/
For copyright information on any of the above toolkits see the corresponding home page or the corresponding source folder.
*/
diff --git a/Examples/FirstSteps/NewModule/autoload/IO/CMakeLists.txt b/Examples/FirstSteps/NewModule/autoload/IO/CMakeLists.txt
index 24b2612a99..06b8804507 100644
--- a/Examples/FirstSteps/NewModule/autoload/IO/CMakeLists.txt
+++ b/Examples/FirstSteps/NewModule/autoload/IO/CMakeLists.txt
@@ -1,8 +1,14 @@
MITK_CREATE_MODULE( NewModuleIO
INCLUDE_DIRS
PRIVATE src/IO
DEPENDS PUBLIC MitkNewModule MitkSceneSerialization
PACKAGE_DEPENDS
- PRIVATE tinyxml
+ PRIVATE tinyxml2|tinyxml2
AUTOLOAD_WITH MitkCore
)
+
+if(TARGET ${MODULE_TARGET})
+ target_link_libraries(${MODULE_TARGET}
+ PRIVATE tinyxml2::tinyxml2
+ )
+endif()
diff --git a/Modules/CEST/autoload/IO/resource/cest_DKFZ.xml b/Modules/CEST/autoload/IO/resource/cest_DKFZ.xml
index b87f554740..6a35902e76 100644
--- a/Modules/CEST/autoload/IO/resource/cest_DKFZ.xml
+++ b/Modules/CEST/autoload/IO/resource/cest_DKFZ.xml
@@ -1,11 +1,11 @@
-
+
-
\ No newline at end of file
+
diff --git a/Modules/CameraCalibration/mitkCameraIntrinsics.cpp b/Modules/CameraCalibration/mitkCameraIntrinsics.cpp
index cb81b0f60b..fbb1ce2894 100644
--- a/Modules/CameraCalibration/mitkCameraIntrinsics.cpp
+++ b/Modules/CameraCalibration/mitkCameraIntrinsics.cpp
@@ -1,507 +1,508 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include "mitkCameraIntrinsics.h"
#include
#include
#include
+#include
mitk::CameraIntrinsics::CameraIntrinsics()
: m_Valid(false), m_Mutex(itk::FastMutexLock::New())
{
m_CameraMatrix = cv::Mat::zeros(3, 3, cv::DataType::type);
m_CameraMatrix.at(2,2) = 1.0;
m_DistorsionCoeffs = cv::Mat::zeros(1, 5, cv::DataType::type);
}
mitk::CameraIntrinsics::CameraIntrinsics(const CameraIntrinsics& other)
: itk::Object()
, mitk::XMLSerializable()
, m_Valid(false)
, m_Mutex(itk::FastMutexLock::New())
{
this->Copy(&other);
}
mitk::CameraIntrinsics::~CameraIntrinsics()
{
}
bool mitk::CameraIntrinsics::Equals( const CameraIntrinsics* other ) const
{
return other->GetDistorsionCoeffsAsPoint4D()==
this->GetDistorsionCoeffsAsPoint4D() &&
other->GetFocalPoint()==
this->GetFocalPoint() &&
other->GetPrincipalPoint()
== this->GetPrincipalPoint();
}
void mitk::CameraIntrinsics::Copy(const CameraIntrinsics* other)
{
this->SetIntrinsics( other->GetCameraMatrix().clone()
, other->GetDistorsionCoeffs().clone() );
this->SetValid(other->m_Valid);
}
bool mitk::CameraIntrinsics::IsValid() const
{
itk::MutexLockHolder lock(*m_Mutex);
return m_Valid;
}
vnl_matrix_fixed
mitk::CameraIntrinsics::GetVnlCameraMatrix() const
{
vnl_matrix_fixed mat;
mat.set_identity();
{
itk::MutexLockHolder lock(*m_Mutex);
mat(0,0) = m_CameraMatrix.at(0,0);
mat(1,1) = m_CameraMatrix.at(1,1);
mat(0,2) = m_CameraMatrix.at(0,2);
mat(1,2) = m_CameraMatrix.at(1,2);
}
return mat;
}
void mitk::CameraIntrinsics::SetCameraMatrix(
const vnl_matrix_fixed& _CameraMatrix )
{
itk::MutexLockHolder lock(*m_Mutex);
m_CameraMatrix.at(0,0) = _CameraMatrix(0,0);
m_CameraMatrix.at(1,1) = _CameraMatrix(1,1);
m_CameraMatrix.at(0,2) = _CameraMatrix(0,2);
m_CameraMatrix.at(1,2) = _CameraMatrix(1,2);
}
vnl_matrix_fixed
mitk::CameraIntrinsics::GetVnlCameraMatrix3x4() const
{
vnl_matrix_fixed mat;
mat.fill(0);
mat.update( this->GetVnlCameraMatrix().as_matrix() );
return mat;
}
void mitk::CameraIntrinsics::SetIntrinsics( const cv::Mat& _CameraMatrix
, const cv::Mat& _DistorsionCoeffs)
{
{
itk::MutexLockHolder lock(*m_Mutex);
if( _CameraMatrix.cols != 3 || _CameraMatrix.rows != 3)
throw std::invalid_argument("Wrong format of camera matrix. Should be 3x3"
" double.");
endoAssertMsg( (_DistorsionCoeffs.cols == 5) &&
_DistorsionCoeffs.rows == 1, "Wrong format of distorsion coefficients"
" vector. Should be 5x1 double.");
m_CameraMatrix = _CameraMatrix.clone();
m_DistorsionCoeffs = _DistorsionCoeffs.clone();
m_Valid = true;
}
this->Modified();
}
void mitk::CameraIntrinsics::SetIntrinsics( const mitk::Point3D& focalPoint,
const mitk::Point3D& principalPoint,
const mitk::Point4D& distortionCoefficients)
{
{
itk::MutexLockHolder lock(*m_Mutex);
m_CameraMatrix.at(0,0) = focalPoint[0];
m_CameraMatrix.at(1,1) = focalPoint[1];
m_CameraMatrix.at(0,2) = principalPoint[0];
m_CameraMatrix.at(1,2) = principalPoint[1];
m_DistorsionCoeffs.at(0,0) = distortionCoefficients[0];
m_DistorsionCoeffs.at(0,1) = distortionCoefficients[1];
m_DistorsionCoeffs.at(0,2) = distortionCoefficients[2];
m_DistorsionCoeffs.at(0,3) = distortionCoefficients[3];
}
this->Modified();
}
void mitk::CameraIntrinsics::SetFocalLength( double x, double y )
{
{
itk::MutexLockHolder lock(*m_Mutex);
m_CameraMatrix.at(0,0) = x;
m_CameraMatrix.at(1,1) = y;
}
this->Modified();
}
void mitk::CameraIntrinsics::SetPrincipalPoint( double x, double y )
{
{
itk::MutexLockHolder lock(*m_Mutex);
m_CameraMatrix.at(0,2) = x;
m_CameraMatrix.at(1,2) = y;
}
this->Modified();
}
void mitk::CameraIntrinsics::SetDistorsionCoeffs( double k1, double k2,
double p1, double p2 )
{
{
itk::MutexLockHolder lock(*m_Mutex);
m_DistorsionCoeffs.at(0,0) = k1;
m_DistorsionCoeffs.at(0,1) = k2;
m_DistorsionCoeffs.at(0,2) = p1;
m_DistorsionCoeffs.at(0,3) = p2;
}
this->Modified();
}
cv::Mat mitk::CameraIntrinsics::GetCameraMatrix() const
{
itk::MutexLockHolder lock(*m_Mutex);
return m_CameraMatrix.clone(); // return a copy of this small matrix
}
cv::Mat mitk::CameraIntrinsics::GetDistorsionCoeffs() const
{
itk::MutexLockHolder lock(*m_Mutex);
return m_DistorsionCoeffs.clone(); // return a copy of this small matrix
}
cv::Mat mitk::CameraIntrinsics::GetDistorsionCoeffs()
{
const CameraIntrinsics* intrinsics = this;
return intrinsics->GetDistorsionCoeffs();
}
std::string mitk::CameraIntrinsics::ToString() const
{
itk::MutexLockHolder lock(*m_Mutex);
std::ostringstream s; s.precision(12);
const cv::Mat& CameraMatrix = m_CameraMatrix;
const cv::Mat& DistorsionCoeffs = m_DistorsionCoeffs;
s.str(""); s << this->GetNameOfClass() << ": ";
s << "fx = " << CameraMatrix.at(0,0);
s << ", fy = " << CameraMatrix.at(1,1);
s << ", cx = " << CameraMatrix.at(0,2);
s << ", cy = " << CameraMatrix.at(1,2);
s << ", k1 = " << DistorsionCoeffs.at(0,0);
s << ", k2 = " << DistorsionCoeffs.at(0,1);
s << ", p1 = " << DistorsionCoeffs.at(0,2);
s << ", p2 = " << DistorsionCoeffs.at(0,3);
//s << ", k3 = " << DistorsionCoeffs.at(0,4);
return s.str();
}
-void mitk::CameraIntrinsics::ToXML(TiXmlElement* elem) const
+void mitk::CameraIntrinsics::ToXML(tinyxml2::XMLElement* elem) const
{
itk::MutexLockHolder lock(*m_Mutex);
elem->SetValue(this->GetNameOfClass());
std::ostringstream s; s.precision(12);
const cv::Mat& CameraMatrix = m_CameraMatrix;
s.str(""); s << CameraMatrix.at(0,0);
- elem->SetAttribute( "fx", s.str() );
+ elem->SetAttribute( "fx", s.str().c_str() );
s.str(""); s << CameraMatrix.at(1,1);
- elem->SetAttribute( "fy", s.str() );
+ elem->SetAttribute( "fy", s.str().c_str());
s.str(""); s << CameraMatrix.at(0,2);
- elem->SetAttribute( "cx", s.str() );
+ elem->SetAttribute( "cx", s.str().c_str());
s.str(""); s << CameraMatrix.at(1,2);
- elem->SetAttribute( "cy", s.str() );
+ elem->SetAttribute( "cy", s.str().c_str());
const cv::Mat& DistorsionCoeffs = m_DistorsionCoeffs;
s.str(""); s << DistorsionCoeffs.at(0,0);
- elem->SetAttribute( "k1", s.str() );
+ elem->SetAttribute( "k1", s.str().c_str());
s.str(""); s << DistorsionCoeffs.at(0,1);
- elem->SetAttribute( "k2", s.str() );
+ elem->SetAttribute( "k2", s.str().c_str());
s.str(""); s << DistorsionCoeffs.at(0,2);
- elem->SetAttribute( "p1", s.str() );
+ elem->SetAttribute( "p1", s.str().c_str());
s.str(""); s << DistorsionCoeffs.at(0,3);
- elem->SetAttribute( "p2", s.str() );
- elem->SetAttribute("Valid", m_Valid);
+ elem->SetAttribute( "p2", s.str().c_str());
+ elem->SetAttribute("Valid", static_cast(m_Valid));
//s.str(""); s << DistorsionCoeffs.at(4,0);
- //elem->SetAttribute( "k3", s.str() );
+ //elem->SetAttribute( "k3", s.str().c_str() );
}
-void mitk::CameraIntrinsics::FromGMLCalibrationXML(TiXmlElement* elem)
+void mitk::CameraIntrinsics::FromGMLCalibrationXML(const tinyxml2::XMLElement* elem)
{
assert( elem );
- assert( elem->ValueStr() == "results" );
+ assert( std::string(elem->Value()) == "results" );
cv::Mat CameraMatrix = cv::Mat::zeros(3, 3, cv::DataType::type);
CameraMatrix.at(2,2) = 1.0;
cv::Mat DistorsionCoeffs = cv::Mat::zeros(1, 5, cv::DataType::type);
- TiXmlElement* focus_lenXElem = elem->FirstChildElement("focus_lenX");
+ const auto* focus_lenXElem = elem->FirstChildElement("focus_lenX");
endoAssert( focus_lenXElem != nullptr );
CameraMatrix.at(0,0) = atof( focus_lenXElem->GetText() );
- TiXmlElement* focus_lenYElem = elem->FirstChildElement("focus_lenY");
+ const auto* focus_lenYElem = elem->FirstChildElement("focus_lenY");
endoAssert( focus_lenYElem != nullptr );
CameraMatrix.at(1,1) = atof( focus_lenYElem->GetText() );
- TiXmlElement* PrincipalXElem = elem->FirstChildElement("PrincipalX");
+ const auto* PrincipalXElem = elem->FirstChildElement("PrincipalX");
endoAssert( PrincipalXElem != nullptr );
CameraMatrix.at(0,2) = atof( PrincipalXElem->GetText() );
- TiXmlElement* PrincipalYElem = elem->FirstChildElement("PrincipalY");
+ const auto* PrincipalYElem = elem->FirstChildElement("PrincipalY");
endoAssert( PrincipalYElem != nullptr );
CameraMatrix.at(1,2) = atof( PrincipalYElem->GetText() );
// DISTORSION COEFFS
- TiXmlElement* Dist1Elem = elem->FirstChildElement("Dist1");
+ const auto* Dist1Elem = elem->FirstChildElement("Dist1");
endoAssert( Dist1Elem != nullptr );
DistorsionCoeffs.at(0,0) = atof( Dist1Elem->GetText() );
- TiXmlElement* Dist2Elem = elem->FirstChildElement("Dist2");
+ const auto* Dist2Elem = elem->FirstChildElement("Dist2");
endoAssert( Dist2Elem != nullptr );
DistorsionCoeffs.at(0,1) = atof( Dist2Elem->GetText() );
- TiXmlElement* Dist3Elem = elem->FirstChildElement("Dist3");
+ const auto* Dist3Elem = elem->FirstChildElement("Dist3");
endoAssert( Dist3Elem != nullptr );
DistorsionCoeffs.at(0,2) = atof( Dist3Elem->GetText() );
- TiXmlElement* Dist4Elem = elem->FirstChildElement("Dist4");
+ const auto* Dist4Elem = elem->FirstChildElement("Dist4");
endoAssert( Dist4Elem != nullptr );
DistorsionCoeffs.at(0,3) = atof( Dist4Elem->GetText() );
int valid = 0;
elem->QueryIntAttribute("Valid", &valid);
{
itk::MutexLockHolder lock(*m_Mutex);
m_Valid = static_cast(valid);
m_CameraMatrix = CameraMatrix;
m_DistorsionCoeffs = DistorsionCoeffs;
}
this->Modified();
}
-void mitk::CameraIntrinsics::FromXML(TiXmlElement* elem)
+void mitk::CameraIntrinsics::FromXML(const tinyxml2::XMLElement* elem)
{
endoAssert ( elem );
MITK_DEBUG << elem->Value();
- std::string filename;
- if(elem->QueryStringAttribute("file", &filename) == TIXML_SUCCESS)
+ const char* filename = elem->Attribute("file");
+ if(nullptr != filename)
{
this->FromXMLFile(filename);
return;
}
else if(strcmp(elem->Value(), "CalibrationProject") == 0)
{
this->FromGMLCalibrationXML(elem->FirstChildElement("results"));
return;
}
assert ( elem );
if(strcmp(elem->Value(), this->GetNameOfClass()) != 0)
elem = elem->FirstChildElement(this->GetNameOfClass());
std::ostringstream err;
// CAMERA MATRIX
cv::Mat CameraMatrix = cv::Mat::zeros(3, 3, cv::DataType::type);
CameraMatrix.at(2,2) = 1.0;
double val = 0.0;
- if(elem->QueryDoubleAttribute("fx", &val) == TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("fx", &val) == tinyxml2::XML_SUCCESS)
CameraMatrix.at(0,0) = val;
else
err << "fx, ";
- if(elem->QueryDoubleAttribute("fy", &val) == TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("fy", &val) == tinyxml2::XML_SUCCESS)
CameraMatrix.at(1,1) = val;
else
err << "fy, ";
- if(elem->QueryDoubleAttribute("cx", &val) == TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("cx", &val) == tinyxml2::XML_SUCCESS)
CameraMatrix.at(0,2) = val;
else
err << "cx, ";
- if(elem->QueryDoubleAttribute("cy", &val) == TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("cy", &val) == tinyxml2::XML_SUCCESS)
CameraMatrix.at(1,2) = val;
else
err << "cy, ";
// DISTORSION COEFFS
endodebug( "creating DistorsionCoeffs from XML file")
cv::Mat DistorsionCoeffs = cv::Mat::zeros(1, 5, cv::DataType::type);
- if(elem->QueryDoubleAttribute("k1", &val) == TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("k1", &val) == tinyxml2::XML_SUCCESS)
DistorsionCoeffs.at(0,0) = val;
else
err << "k1, ";
- if(elem->QueryDoubleAttribute("k2", &val) == TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("k2", &val) == tinyxml2::XML_SUCCESS)
DistorsionCoeffs.at(0,1) = val;
else
err << "k2, ";
- if(elem->QueryDoubleAttribute("p1", &val) == TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("p1", &val) == tinyxml2::XML_SUCCESS)
DistorsionCoeffs.at(0,2) = val;
else
err << "p1, ";
- if(elem->QueryDoubleAttribute("p2", &val) == TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("p2", &val) == tinyxml2::XML_SUCCESS)
DistorsionCoeffs.at(0,3) = val;
else
err << "p2, ";
DistorsionCoeffs.at(0,4) = 0.0;
- /*if(elem->QueryDoubleAttribute("k3", &val) == TIXML_SUCCESS)
+ /*if(elem->QueryDoubleAttribute("k3", &val) == tinyxml2::XML_SUCCESS)
DistorsionCoeffs.at(4,0) = val;
else
err << "k3, ";*/
std::string errorStr = err.str();
int errLength = errorStr.length();
if(errLength > 0)
{
errorStr = errorStr.substr(0, errLength-2);
errorStr.append(" not found");
throw std::invalid_argument(err.str());
}
int valid = 0;
elem->QueryIntAttribute("Valid", &valid);
{
itk::MutexLockHolder lock(*m_Mutex);
m_Valid = static_cast(valid);
m_CameraMatrix = CameraMatrix;
m_DistorsionCoeffs = DistorsionCoeffs;
}
this->Modified();
}
double mitk::CameraIntrinsics::GetFocalLengthX() const
{
itk::MutexLockHolder lock(*m_Mutex);
double FocalLengthX = m_CameraMatrix.at(0,0);
return FocalLengthX;
}
double mitk::CameraIntrinsics::GetFocalLengthY() const
{
itk::MutexLockHolder lock(*m_Mutex);
double FocalLengthY = m_CameraMatrix.at(1,1);;
return FocalLengthY;
}
double mitk::CameraIntrinsics::GetPrincipalPointX() const
{
itk::MutexLockHolder lock(*m_Mutex);
double PrincipalPointX = m_CameraMatrix.at(0,2);
return PrincipalPointX;
}
double mitk::CameraIntrinsics::GetPrincipalPointY() const
{
itk::MutexLockHolder lock(*m_Mutex);
double PrincipalPointY = m_CameraMatrix.at(1,2);
return PrincipalPointY;
}
mitk::Point4D mitk::CameraIntrinsics::GetDistorsionCoeffsAsPoint4D() const
{
itk::MutexLockHolder lock(*m_Mutex);
mitk::Point4D coeffs;
coeffs[0] = m_DistorsionCoeffs.at(0,0);
coeffs[1] = m_DistorsionCoeffs.at(0,1);
coeffs[2] = m_DistorsionCoeffs.at(0,2);
coeffs[3] = m_DistorsionCoeffs.at(0,3);
return coeffs;
}
mitk::Point3D mitk::CameraIntrinsics::GetFocalPoint() const
{
mitk::Point3D p;
p[0] = this->GetFocalLengthX();
p[1] = this->GetFocalLengthY();
p[2] = 0;
return p;
}
mitk::Point3D mitk::CameraIntrinsics::GetPrincipalPoint() const
{
mitk::Point3D p;
p[0] = this->GetPrincipalPointX();
p[1] = this->GetPrincipalPointY();
p[2] = 0;
return p;
}
vnl_vector_fixed
mitk::CameraIntrinsics::GetFocalPointAsVnlVector() const
{
vnl_vector_fixed vec;
vec[0] = this->GetFocalLengthX();
vec[1] = this->GetFocalLengthY();
return vec;
}
vnl_vector_fixed
mitk::CameraIntrinsics::GetPrincipalPointAsVnlVector() const
{
vnl_vector_fixed vec;
vec[0] = this->GetPrincipalPointX();
vec[1] = this->GetPrincipalPointY();
return vec;
}
std::ostream& operator<< (std::ostream& os, mitk::CameraIntrinsics::Pointer p)
{
os << p->ToString();
return os;
}
std::string mitk::CameraIntrinsics::GetString()
{
return this->ToString();
}
std::string mitk::CameraIntrinsics::ToOctaveString(
const std::string& varName)
{
std::ostringstream s;
s << varName << " = [" << this->GetFocalLengthX() << " 0 "
<< this->GetPrincipalPointX() << "; 0 " <<
this->GetFocalLengthY() << " " << this->GetPrincipalPointY() << ";"
<< " 0 0 1 ];";
return s.str();
}
void mitk::CameraIntrinsics::SetValid( bool valid )
{
itk::MutexLockHolder lock(*m_Mutex);
m_Valid = valid;
}
itk::LightObject::Pointer mitk::CameraIntrinsics::InternalClone() const
{
itk::LightObject::Pointer result(new Self(*this));
result->UnRegister();
return result;
}
diff --git a/Modules/CameraCalibration/mitkCameraIntrinsics.h b/Modules/CameraCalibration/mitkCameraIntrinsics.h
index a6004b8960..a36cbf0a7f 100644
--- a/Modules/CameraCalibration/mitkCameraIntrinsics.h
+++ b/Modules/CameraCalibration/mitkCameraIntrinsics.h
@@ -1,141 +1,141 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#ifndef mitkCameraIntrinsics_h
#define mitkCameraIntrinsics_h
#include
#include
#include
#include
#include
#include "mitkXMLSerializable.h"
#include
#include "opencv2/core.hpp"
int mitkCameraIntrinsicsTest(int, char* []);
namespace mitk
{
///
/// \brief class representing camera intrinsics and related functions
///
class MITKCAMERACALIBRATION_EXPORT CameraIntrinsics: virtual public itk::Object,
virtual public mitk::XMLSerializable
{
public:
///
/// for testing purposes
///
friend int mitkCameraIntrinsicsTest(int argc, char* argv[]);
///
/// smartpointer typedefs
///
mitkClassMacroItkParent(CameraIntrinsics, itk::Object);
///
/// the static new function
///
itkFactorylessNewMacro(Self);
///
/// make a clone of this intrinsics
///
itkCloneMacro(Self);
///
/// copy information from other to this
///
void Copy(const CameraIntrinsics* other);
///
/// checks two intrinsics for equality
///
bool Equals( const CameraIntrinsics* other ) const;
///
/// \return the intrinsic parameter matrix as a 3x3 vnl matrix
///
vnl_matrix_fixed GetVnlCameraMatrix() const;
///
/// \return the intrinsic parameter matrix as a 3x4 vnl matrix
/// (the last column only containing zeros)
///
vnl_matrix_fixed GetVnlCameraMatrix3x4() const;
///
/// \return true if the intrinsics are set (some plausibility checks
/// may be done here)
///
bool IsValid() const;
void SetValid(bool valid);
cv::Mat GetCameraMatrix() const;
cv::Mat GetDistorsionCoeffs();
cv::Mat GetDistorsionCoeffs() const;
- void ToXML(TiXmlElement* elem) const override;
+ void ToXML(tinyxml2::XMLElement* elem) const override;
std::string ToString() const;
std::string GetString();
double GetFocalLengthX() const;
double GetFocalLengthY() const;
double GetPrincipalPointX() const;
double GetPrincipalPointY() const;
mitk::Point4D GetDistorsionCoeffsAsPoint4D() const;
mitk::Point3D GetFocalPoint() const;
mitk::Point3D GetPrincipalPoint() const;
vnl_vector_fixed GetFocalPointAsVnlVector() const;
vnl_vector_fixed GetPrincipalPointAsVnlVector() const;
///
/// set a new camera matrix utilizing a vnl matrix
///
void SetCameraMatrix( const vnl_matrix_fixed&
_CameraMatrix );
void SetIntrinsics( const cv::Mat& _CameraMatrix
, const cv::Mat& _DistorsionCoeffs);
void SetFocalLength( double x, double y );
void SetPrincipalPoint( double x, double y );
void SetDistorsionCoeffs( double k1, double k2, double p1, double p2 );
void SetIntrinsics( const mitk::Point3D& focalPoint,
const mitk::Point3D& principalPoint,
const mitk::Point4D& distortionCoefficients);
- void FromXML(TiXmlElement* elem) override;
- void FromGMLCalibrationXML(TiXmlElement* elem);
+ void FromXML(const tinyxml2::XMLElement* elem) override;
+ void FromGMLCalibrationXML(const tinyxml2::XMLElement* elem);
std::string ToOctaveString(const std::string& varName="CameraIntrinsics");
~CameraIntrinsics() override;
protected:
CameraIntrinsics();
CameraIntrinsics(const CameraIntrinsics& other);
cv::Mat m_CameraMatrix;
cv::Mat m_DistorsionCoeffs;
bool m_Valid;
itk::FastMutexLock::Pointer m_Mutex;
private:
itk::LightObject::Pointer InternalClone() const override;
};
} // namespace mitk
MITKCAMERACALIBRATION_EXPORT std::ostream& operator<<
(std::ostream& os, mitk::CameraIntrinsics::Pointer p);
#endif // mitkCameraIntrinsics_h
diff --git a/Modules/CameraCalibration/mitkEndoDebugFromXmlFile.cpp b/Modules/CameraCalibration/mitkEndoDebugFromXmlFile.cpp
index a88a588b80..e9b827e034 100644
--- a/Modules/CameraCalibration/mitkEndoDebugFromXmlFile.cpp
+++ b/Modules/CameraCalibration/mitkEndoDebugFromXmlFile.cpp
@@ -1,159 +1,169 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include "mitkEndoDebugFromXmlFile.h"
#include
-#include
+#include
#include
using namespace std;
namespace mitk
{
struct EndoDebugFromXmlFileData
{
const std::string* m_FileName;
// private
EndoDebug* m_EndoDebug;
long int m_FileModifiedTime;
};
EndoDebugFromXmlFile::EndoDebugFromXmlFile(
const std::string* _FileName, EndoDebug* _EndoDebug )
: d( new EndoDebugFromXmlFileData )
{
d->m_FileName = _FileName;
d->m_EndoDebug = _EndoDebug;
d->m_FileModifiedTime = 0;
}
EndoDebugFromXmlFile::~EndoDebugFromXmlFile()
{
delete d;
}
void StringExplode(string str, string separator, set* results){
std::size_t found;
found = str.find_first_of(separator);
while(found != string::npos){
if(found != 0){
results->insert(str.substr(0,found));
}
str = str.substr(found+1);
found = str.find_first_of(separator);
}
if(!str.empty()){
results->insert(str);
}
}
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable:4390)
#endif
void EndoDebugFromXmlFile::Update()
{
endodebug( __FUNCTION__ )
std::string _FileName = *d->m_FileName;
if( !itksys::SystemTools::FileExists( _FileName.c_str() ) )
{
endodebug(_FileName << " does not exist");
return;
}
long int _FileModifiedTime
= itksys::SystemTools::ModifiedTime( _FileName.c_str() );
// file has changed: we know an older version...
if( d->m_FileModifiedTime >= _FileModifiedTime )
{
endodebug("File not changed. No Update necessary.");
return;
}
// reread
- endodebugvar( _FileName )
- TiXmlDocument doc( _FileName );
- doc.LoadFile();
- TiXmlHandle docHandle( &doc );
- TiXmlElement* elem = docHandle.FirstChildElement().FirstChildElement( "EndoDebug" ).ToElement();
+ endodebugvar(_FileName)
+ tinyxml2::XMLDocument doc;
+ doc.LoadFile(_FileName.c_str());
+ tinyxml2::XMLHandle docHandle(&doc);
+ auto* elem = docHandle.FirstChildElement().FirstChildElement( "EndoDebug" ).ToElement();
if(elem == nullptr)
{
endodebug("EndoDebug element not found");
return;
}
int _DebugEnabled = d->m_EndoDebug->GetDebugEnabled();
- if( elem->QueryIntAttribute("DebugEnabled",&_DebugEnabled) != TIXML_SUCCESS )
+ if( elem->QueryIntAttribute("DebugEnabled",&_DebugEnabled) != tinyxml2::XML_SUCCESS )
{
endodebug("DebugEnabled attribute not found");
}
int _ShowImagesInDebug = d->m_EndoDebug->GetShowImagesInDebug();
- if( elem->QueryIntAttribute("ShowImagesInDebug",&_ShowImagesInDebug) != TIXML_SUCCESS )
+ if( elem->QueryIntAttribute("ShowImagesInDebug",&_ShowImagesInDebug) != tinyxml2::XML_SUCCESS)
{
endodebug("ShowImagesInDebug attribute not found");
}
int _ShowImagesTimeOut = static_cast(d->m_EndoDebug->GetShowImagesTimeOut());
- if( elem->QueryIntAttribute("ShowImagesTimeOut",&_ShowImagesTimeOut) != TIXML_SUCCESS )
+ if( elem->QueryIntAttribute("ShowImagesTimeOut",&_ShowImagesTimeOut) != tinyxml2::XML_SUCCESS)
{
endodebug("ShowImagesTimeOut attribute not found");
}
- std::string _DebugImagesOutputDirectory = d->m_EndoDebug->GetDebugImagesOutputDirectory();
- if( elem->QueryStringAttribute("DebugImagesOutputDirectory",&_DebugImagesOutputDirectory) != TIXML_SUCCESS )
+ std::string _DebugImagesOutputDirectory;
+ const char* _DebugImagesOutputDirectoryC = elem->Attribute("DebugImagesOutputDirectory");
+ if(nullptr == _DebugImagesOutputDirectoryC)
{
+ _DebugImagesOutputDirectory = d->m_EndoDebug->GetDebugImagesOutputDirectory();
endodebug("DebugImagesOutputDirectory attribute not found");
}
+ else
+ {
+ _DebugImagesOutputDirectory = _DebugImagesOutputDirectoryC;
+ }
std::set _FilesToDebug;
std::string _FilesToDebugString;
- if( elem->QueryStringAttribute("FilesToDebug",&_FilesToDebugString) != TIXML_SUCCESS )
+ const char* _FilesToDebugStringC = elem->Attribute("FilesToDebug");
+ if(nullptr == _FilesToDebugStringC)
{
endodebug("FilesToDebug attribute not found");
}
else
{
- StringExplode( _FilesToDebugString, ";", &_FilesToDebug );
+ _FilesToDebugString = _FilesToDebugStringC;
+ StringExplode( _FilesToDebugString, ";", &_FilesToDebug );
}
std::set _SymbolsToDebug;
std::string _SymbolsToDebugString;
- if( elem->QueryStringAttribute("SymbolsToDebug",&_SymbolsToDebugString) != TIXML_SUCCESS )
+ const char* _SymbolsToDebugStringC = elem->Attribute("SymbolsToDebug");
+ if( nullptr == _SymbolsToDebugStringC )
{
endodebug("SymbolsToDebug attribute not found");
}
else
{
- StringExplode( _SymbolsToDebugString, ";", &_SymbolsToDebug );
+ _SymbolsToDebugString = _SymbolsToDebugStringC;
+ StringExplode( _SymbolsToDebugString, ";", &_SymbolsToDebug );
}
// save
mitk::EndoDebug::GetInstance().SetDebugEnabled( _DebugEnabled == 1? true: false );
mitk::EndoDebug::GetInstance().SetShowImagesInDebug( _ShowImagesInDebug == 1? true: false );
mitk::EndoDebug::GetInstance().SetShowImagesTimeOut( _ShowImagesTimeOut );
mitk::EndoDebug::GetInstance().SetDebugImagesOutputDirectory( _DebugImagesOutputDirectory );
mitk::EndoDebug::GetInstance().SetFilesToDebug(_FilesToDebug);
mitk::EndoDebug::GetInstance().SetSymbolsToDebug(_SymbolsToDebug);
// save that modified time
d->m_FileModifiedTime = _FileModifiedTime;
}
#ifdef _MSC_VER
# pragma warning(pop)
#endif
}
diff --git a/Modules/CameraCalibration/mitkEndoDebugToXmlFile.cpp b/Modules/CameraCalibration/mitkEndoDebugToXmlFile.cpp
index 8e0a52463c..82a0e184c1 100644
--- a/Modules/CameraCalibration/mitkEndoDebugToXmlFile.cpp
+++ b/Modules/CameraCalibration/mitkEndoDebugToXmlFile.cpp
@@ -1,121 +1,122 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include "mitkEndoDebugToXmlFile.h"
-#include
+#include
namespace mitk
{
struct EndoDebugToXmlFileData
{
EndoDebug* m_EndoDebug;
const std::string* m_FileName;
};
EndoDebugToXmlFile::EndoDebugToXmlFile(EndoDebug *_EndoDebug,
const std::string* _FileName)
: d( new EndoDebugToXmlFileData )
{
d->m_EndoDebug = _EndoDebug;
d->m_FileName = _FileName;
}
EndoDebugToXmlFile::~EndoDebugToXmlFile()
{
delete d;
}
void EndoDebugToXmlFile::Update()
{
std::string _FileName = *d->m_FileName;
- TiXmlDocument doc( _FileName.c_str() );
- TiXmlElement* root = nullptr;
- TiXmlElement* elem = nullptr;
+ tinyxml2::XMLDocument doc;
+ tinyxml2::XMLElement* root = nullptr;
+ tinyxml2::XMLElement* elem = nullptr;
// check if element is already available
- if(doc.LoadFile())
+ if(tinyxml2::XML_SUCCESS == doc.LoadFile(_FileName.c_str()))
{
root = doc.FirstChildElement("data");
- if(root)
+ if(nullptr != root)
{
elem = root->FirstChildElement( "EndoDebug" );
- if(elem)
- root->RemoveChild(elem);
- elem = nullptr;
+ if (nullptr != elem)
+ {
+ root->DeleteChild(elem);
+ elem = nullptr;
+ }
}
}
else
{
// document did not exist, create new one with declration
- auto decl = new TiXmlDeclaration( "1.0", "", "" );
- doc.LinkEndChild( decl );
+ doc.InsertEndChild( doc.NewDeclaration() );
// create root
- root = new TiXmlElement( "data" );
- doc.LinkEndChild( root );
+ root = doc.NewElement( "data" );
+ doc.InsertEndChild( root );
}
// create elem if not existent
- elem = new TiXmlElement( "EndoDebug" );
+ elem = doc.NewElement( "EndoDebug" );
elem->SetAttribute( "DebugEnabled",
(d->m_EndoDebug->GetDebugEnabled()? 1:0) );
elem->SetAttribute( "ShowImagesInDebug",
(d->m_EndoDebug->GetShowImagesInDebug()? 1:0) );
elem->SetAttribute( "ShowImagesTimeOut",
(static_cast(d->m_EndoDebug->GetShowImagesTimeOut())) );
elem->SetAttribute( "DebugImagesOutputDirectory",
- d->m_EndoDebug->GetDebugImagesOutputDirectory() );
+ d->m_EndoDebug->GetDebugImagesOutputDirectory().c_str() );
std::set _FilesToDebug = d->m_EndoDebug->GetFilesToDebug();
std::string _FilesToDebugString;
auto it = _FilesToDebug.begin();
while( it != _FilesToDebug.end() )
{
if( it != _FilesToDebug.begin() )
_FilesToDebugString.append( ";" );
_FilesToDebugString.append( *it );
++it;
}
- elem->SetAttribute( "FilesToDebug", _FilesToDebugString );
+ elem->SetAttribute( "FilesToDebug", _FilesToDebugString.c_str() );
std::set _SymbolsToDebug = d->m_EndoDebug->GetSymbolsToDebug();
std::string _SymbolsToDebugString;
it = _SymbolsToDebug.begin();
while( it != _SymbolsToDebug.end() )
{
if( it != _SymbolsToDebug.begin() )
_SymbolsToDebugString.append( ";" );
_SymbolsToDebugString.append( *it );
++it;
}
- elem->SetAttribute( "SymbolsToDebug", _SymbolsToDebugString );
+ elem->SetAttribute( "SymbolsToDebug", _SymbolsToDebugString.c_str() );
endodebug("adding the EndoDebug as child element of the data node")
- root->LinkEndChild(elem);
+ root->InsertEndChild(elem);
endodebug("saving file " << _FileName)
- if( !doc.SaveFile( _FileName ) )
+ if( tinyxml2::XML_SUCCESS != doc.SaveFile( _FileName.c_str() ) )
{
endodebug("File " << _FileName << " could not be written. Please check permissions.");
}
}
void EndoDebugToXmlFile::SetEndoDebug(EndoDebug *_EndoDebug)
{
d->m_EndoDebug = _EndoDebug;
}
void EndoDebugToXmlFile::SetFileName(const std::string *_FileName)
{
d->m_FileName = _FileName;
}
}
diff --git a/Modules/CameraCalibration/mitkTransform.cpp b/Modules/CameraCalibration/mitkTransform.cpp
index d77d2d87fe..0a65753afb 100644
--- a/Modules/CameraCalibration/mitkTransform.cpp
+++ b/Modules/CameraCalibration/mitkTransform.cpp
@@ -1,745 +1,750 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include "mitkTransform.h"
#include
#include
#include
#include
#include
#include
+#include
+
namespace mitk
{
// DO NOT CHANGE THE VALUES OF THESE CONSTANTS!!
const std::string Transform::UNKNOWN_TYPE = "Unknown type";
const std::string Transform::ENDOSCOPE_SCOPE_TOOL = "Endoscope scope tool";
const std::string Transform::ENDOSCOPE_CAM_TOOL = "Endoscope camera tool";
const std::string Transform::CHESSBOARD_TOOL = "Chessboard tool";
const std::string Transform::POINTER_TOOL = "Pointer tool";
const std::string Transform::POINTER_TO_CHESSBOARD_ORIGIN = "Pointer to chessboard origin";
const std::string Transform::POINTER_TO_CHESSBOARD_X_SUPPORT_POINT = "Pointer to chessboard X support origin";
const std::string Transform::POINTER_TO_CHESSBOARD_Y_SUPPORT_POINT = "Pointer to chessboard Y support origin";
const std::string Transform::BOARD_TO_BOARD_TOOL = "Board to board tool";
const std::string Transform::REFERENCE_CAMERA_TRANSFORM = "Reference camera transform";
const std::string Transform::REFERENCE_SCOPE_TRANSFORM = "Reference scope transform";
const std::string Transform::EYE_TO_HAND_TRANSFORM = "Eye to hand transform";
const std::string Transform::CAMERA_EXTRINSICS = "Camera extrinsics";
Transform::Transform()
: m_NavData(mitk::NavigationData::New()), m_Type( UNKNOWN_TYPE )
{
vnl_matrix_fixed rot;
rot.set_identity();
this->SetRotation( rot );
}
Transform::Transform(const mitk::NavigationData* nd)
: m_NavData(mitk::NavigationData::New()), m_Type( UNKNOWN_TYPE )
{
m_NavData->Graft(nd);
}
Transform::Transform(const std::string& s)
: m_NavData(mitk::NavigationData::New()), m_Type( s )
{
vnl_matrix_fixed rot;
rot.set_identity();
this->SetRotation( rot );
}
void Transform::Copy(const mitk::NavigationData* nd)
{
(const_cast(m_NavData.GetPointer()))->Graft(nd);
}
void Transform::Concatenate( mitk::Transform* transform )
{
vnl_matrix_fixed mat = transform->GetMatrix();
mat = mat * this->GetMatrix(); //
this->SetMatrix( mat );
}
void Transform::Concatenate( const vnl_matrix_fixed&
transform )
{
Transform::Pointer t = Transform::New();
t->SetMatrix( transform );
this->Concatenate( t );
}
void Transform::Concatenate( const vtkMatrix4x4* transform )
{
Transform::Pointer t = Transform::New();
t->SetMatrix( transform );
this->Concatenate( t );
}
void Transform::Reset()
{
mitk::NavigationData::Pointer nd
= NavigationData::New();
this->Copy( nd );
}
void Transform::SetOrientation(
const vnl_quaternion& orientation)
{
m_NavData->SetOrientation(orientation);
this->Modified();
}
void Transform::SetTranslation( const vnl_vector_fixed&
transl)
{
mitk::Point3D p;
for(unsigned int i=0; i<3; ++i)
p[i] = transl[i];
m_NavData->SetPosition(p);
this->Modified();
}
void Transform::SetTranslation( float* array )
{
vnl_vector_fixed vec;
for(unsigned int i=0; iSetTranslation( vec );
}
void Transform::SetRotation( float* array )
{
vnl_matrix_fixed mat;
unsigned int row = 0;
unsigned int col = 0;
for(unsigned int i=0; i 0 && i % 3 == 0 )
{
++row;
col = 0;
}
mat(row,col) = array[i];
++col;
}
this->SetRotation( mat );
}
void Transform::SetOrientation( const vnl_quaternion& orientation)
{
vnl_vector_fixed qvec;
VnlVectorFixedCaster caster( &orientation, &qvec );
caster.Update();
mitk::Quaternion p( qvec );
this->SetOrientation( p );
}
vnl_vector_fixed Transform::GetVnlDoubleTranslation() const
{
vnl_vector_fixed vecFloat = this->GetVnlTranslation();
vnl_vector_fixed vecDouble;
VnlVectorFixedCaster caster( &vecFloat, &vecDouble );
caster.Update();
return vecDouble;
}
void Transform::SetTranslation( const vnl_vector& transl)
{
vnl_vector_fixed dTransl(transl);
vnl_vector_fixed fTransl;
VnlVectorFixedCaster caster( &dTransl, &fTransl );
caster.Update();
this->SetTranslation( fTransl );
}
vnl_quaternion Transform::GetVnlDoubleQuaternion() const
{
mitk::Quaternion fOrientation = this->GetOrientation();
vnl_quaternion dOrientation;
VnlVectorFixedCaster caster( &fOrientation, &dOrientation );
caster.Update();
return dOrientation;
}
void Transform::FromCSVFile(const std::string& file)
{
std::ifstream csvFile (file.c_str());
endoAssert ( csvFile.fail() == false );
mitk::Transform::Pointer transform = mitk::Transform::New();
vnl_matrix_fixed mat;
std::string line;
mitk::ScalarType d = 0.0f;
int row=0,column = 0;
while (std::getline (csvFile, line))
{
std::istringstream linestream(line);
std::string item;
column = 0;
while (std::getline (linestream, item, ','))
{
std::istringstream number;
number.str(item);
number >> d;
mat(row, column) = d;
++column;
}
++row;
}
endoAssert( row == 4 && column == 4 );
transform->SetMatrix( mat );
this->SetNavigationData( transform->GetNavigationData() );
// modified is called in SetNavigationData
}
std::string Transform::ToCSVString() const
{
std::ostringstream s; s.precision(12);
vnl_matrix_fixed mat
= this->GetMatrix();
for( unsigned int j=0; j mat
= this->GetMatrix();
s << varname << " = [";
for( unsigned int j=0; jGraft(transform->GetNavigationData());
m_Type = transform->GetType();
}
mitk::Transform::Pointer Transform::Clone() const
{
Transform::Pointer copy = Transform::New();
copy->Copy( this );
return copy;
}
void Transform::SetMatrix( const vtkMatrix4x4* mat)
{
vnl_matrix_fixed vnlMat;
for(unsigned int i=0; i<4; ++i)
for(unsigned int j=0; j<4; ++j)
vnlMat(i,j) = mat->GetElement(i, j);
this->SetMatrix( vnlMat );
}
void Transform::ToCSVFile(const std::string& file) const
{
std::ofstream csvFile;
csvFile.open(file.c_str());
endoAssert ( csvFile.fail() == false );
csvFile << this->ToCSVString();
csvFile.close();
}
void Transform::ToMatlabFile(const std::string& file
, const std::string& varname) const
{
std::ofstream csvFile;
csvFile.open(file.c_str());
endoAssert ( csvFile.fail() == false );
csvFile << this->ToMatlabString(varname);
csvFile.close();
}
void Transform::SetNavigationData( const mitk::NavigationData* naviData )
{
endoAssert( naviData != nullptr );
m_NavData->Graft( naviData );
this->Modified();
}
void Transform::SetRotation( vnl_matrix_fixed& mat)
{
this->m_NavData->SetOrientation( mitk::Quaternion(mat) );
this->Modified();
}
void Transform::SetRotation( vnl_matrix& mat)
{
vnl_matrix_fixed tmp(mat);
this->SetRotation( tmp );
}
void Transform::SetPosition( const mitk::Point3D& transl)
{
this->SetTranslation( transl.GetVnlVector() );
}
void Transform::SetTranslation( double array[3] )
{
mitk::Point3D p;
for(unsigned int i = 0; i < 3; ++i)
p.SetElement(i, array[i]);
this->SetTranslation( p.GetVnlVector() );
}
void Transform::SetRotation( double array[3][3] )
{
vnl_matrix_fixed mat;
for(unsigned int i = 0; i < 3; ++i)
for(unsigned int j = 0; j < 3; ++j)
mat(i, j) = array[i][j];
this->SetRotation( mat );
}
void Transform::Invert()
{
vnl_matrix_fixed tmp(this->GetMatrix());
this->SetMatrix( vnl_inverse( tmp ) );
}
void Transform::SetMatrix(
const vnl_matrix_fixed& mat)
{
// set translation first
vnl_vector transl = mat.get_column(3);
mitk::Point3D p;
for(unsigned int i=0; i<3; ++i)
p[i] = transl[i];
m_NavData->SetPosition(p);
// set rotation
vnl_matrix_fixed rotMatFixed(
mat.extract(3,3));
this->SetRotation(rotMatFixed);
}
bool Transform::IsValid() const
{
return m_NavData->IsDataValid();
}
void Transform::SetTranslation( const cv::Mat& transl)
{
vnl_vector vec(3);
VnlVectorFromCvMat _VnlVectorFromCvMat( &transl, &vec );
_VnlVectorFromCvMat.Update();
this->SetTranslation( vnl_vector_fixed( vec ) );
}
void Transform::SetRotation( const cv::Mat& mat )
{
vnl_matrix vnlMat(3, 3);
VnlMatrixFromCvMat _VnlMatrixFromCvMat( &mat, &vnlMat );
_VnlMatrixFromCvMat.Update();
vnl_matrix_fixed vnlMatFixed(vnlMat);
this->SetRotation(vnlMatFixed);
}
void Transform::SetRotationVector( const cv::Mat& rotVec )
{
cv::Mat rotMat;
cv::Rodrigues( rotVec, rotMat );
vnl_matrix vnlMat(3, 3);
VnlMatrixFromCvMat _VnlMatrixFromCvMat( &rotMat, &vnlMat );
_VnlMatrixFromCvMat.Update();
vnl_matrix_fixed vnlMatFixed(vnlMat);
this->SetRotation( vnlMatFixed );
}
//# getter
mitk::NavigationData::Pointer Transform::GetNavigationData() const
{
return m_NavData;
}
mitk::Point3D Transform::GetTranslation() const
{
return m_NavData->GetPosition();
}
mitk::Point3D Transform::GetPosition() const
{
return m_NavData->GetPosition();
}
mitk::Quaternion Transform::GetOrientation() const
{
return m_NavData->GetOrientation();
}
void Transform::GetMatrix(vtkMatrix4x4* matrix) const
{
vnl_matrix_fixed vnlMat = this->GetMatrix();
for(unsigned int i=0; iSetElement(i,j, vnlMat(i,j));
}
void Transform::GetVtkOpenGlMatrix(vtkMatrix4x4* matrix) const
{
vnl_matrix vnlRotation
= this->GetVnlRotationMatrix().as_matrix();
// normalize rows of rotation matrix
vnlRotation.normalize_rows();
vnl_matrix vnlInverseRotation(3,3);
// invert rotation
vnlInverseRotation = vnl_matrix_inverse(vnlRotation);
vnl_vector vnlTranslation
= this->GetPosition().GetVnlVector();
// rotate translation vector by inverse rotation P = P'
vnlTranslation = vnlInverseRotation * vnlTranslation;
vnlTranslation *= -1; // save -P'
// set position
mitk::Transform::Pointer tmp = mitk::Transform::New();
tmp->SetTranslation( vnlTranslation );
tmp->SetRotation( vnlRotation );
tmp->GetMatrix(matrix);
}
mitk::Point3D Transform::TransformPoint(mitk::Point3D point) const
{
itk::Matrix R(GetVnlRotationMatrix());
itk::Point pointR = (R * point);
mitk::Point3D retPoint = pointR;
retPoint[0] = pointR[0] + GetPosition()[0];
retPoint[1] = pointR[1] + GetPosition()[1];
retPoint[2] = pointR[2] + GetPosition()[2];
return retPoint;
}
//# cv getter
cv::Mat Transform::GetCvTranslation() const
{
cv::Mat mat;
vnl_vector vec = this->GetVnlTranslation().as_vector();
endodebugvar( vec )
CvMatFromVnlVector _CvMatFromVnlVector(&vec, &mat);
_CvMatFromVnlVector.Update();
return mat;
}
cv::Mat Transform::GetCvRotationMatrix() const
{
cv::Mat mat;
vnl_matrix vec = this->GetVnlRotationMatrix().as_matrix();
endodebugvar( vec )
CvMatFromVnlMatrix _CvMatFromVnlMatrix(&vec, &mat);
_CvMatFromVnlMatrix.Update();
return mat;
}
cv::Mat Transform::GetCvMatrix() const
{
cv::Mat mat;
vnl_matrix vec = this->GetMatrix().as_matrix();
CvMatFromVnlMatrix _CvMatFromVnlMatrix(&vec, &mat);
_CvMatFromVnlMatrix.Update();
return mat;
}
cv::Mat Transform::GetCvRotationVector() const
{
cv::Mat rotVec(3,1,cv::DataType::type);
cv::Rodrigues( this->GetCvRotationMatrix(), rotVec );
return rotVec;
}
//# vnl getter
vnl_vector_fixed Transform::GetVnlTranslation() const
{
vnl_vector_fixed vec(m_NavData->GetPosition()
.GetVnlVector());
return vec;
}
vnl_matrix_fixed Transform::GetVnlRotationMatrix() const
{
return m_NavData->GetOrientation().rotation_matrix_transpose();
}
vnl_matrix_fixed Transform::GetVnlDoubleMatrix() const
{
vnl_matrix_fixed mat = this->GetMatrix();
vnl_matrix_fixed doubleMat;
for(unsigned int i=0; i( mat(i,j) );
return doubleMat;
}
vnl_matrix_fixed Transform::GetMatrix()
const
{
vnl_vector_fixed transl = this->GetVnlTranslation();
vnl_matrix_fixed rot = this->GetVnlRotationMatrix();
vnl_matrix_fixed homMat;
homMat.set_identity();
//std::cout << homMat << std::endl;
for(unsigned int i=0; i rotMat = this->GetVnlRotationMatrix().transpose();
this->SetRotation( rotMat );
}
void Transform::SetValid( bool valid )
{
if( m_NavData->IsDataValid() == valid )
return;
m_NavData->SetDataValid( valid );
this->Modified();
}
std::string mitk::Transform::ToString() const
{
std::ostringstream s; s.precision(12);
mitk::NavigationData::PositionType position;
position.Fill(0.0);
position = m_NavData->GetPosition();
mitk::NavigationData::OrientationType orientation(0.0, 0.0, 0.0, 0.0);
orientation = m_NavData->GetOrientation();
s << "Translation: [" << position[0] << ", " << position[1] << ", "
<< position[2] << "]";
s << ", orientation: [" << orientation[0] << ", " << orientation[1] << ", "
<< orientation[2] << ", " << orientation[3] << "]";
s << ", valid: [" << (this->IsValid()? "true": "false") << "]";
return s.str();
}
- void mitk::Transform::ToXML(TiXmlElement* elem) const
+ void mitk::Transform::ToXML(tinyxml2::XMLElement* elem) const
{
- std::string value = elem->ValueStr();
+ std::string value = elem->Value() != nullptr ? elem->Value() : "";
if(value.empty())
elem->SetValue(this->GetNameOfClass());
mitk::NavigationData::PositionType position;
position.Fill(0.0);
position = m_NavData->GetPosition();
mitk::NavigationData::OrientationType orientation(0.0, 0.0, 0.0, 0.0);
orientation = m_NavData->GetOrientation();
mitk::NavigationData::CovarianceMatrixType matrix;
matrix.SetIdentity();
matrix = m_NavData->GetCovErrorMatrix();
bool hasPosition = true;
hasPosition = m_NavData->GetHasPosition();
bool hasOrientation = true;
hasOrientation = m_NavData->GetHasOrientation();
bool dataValid = false;
dataValid = m_NavData->IsDataValid();
mitk::NavigationData::TimeStampType timestamp=0.0;
- elem->SetAttribute("Type", m_Type);
- elem->SetDoubleAttribute("Time", timestamp);
- elem->SetDoubleAttribute("X", position[0]);
- elem->SetDoubleAttribute("Y", position[1]);
- elem->SetDoubleAttribute("Z", position[2]);
-
- elem->SetDoubleAttribute("QX", orientation[0]);
- elem->SetDoubleAttribute("QY", orientation[1]);
- elem->SetDoubleAttribute("QZ", orientation[2]);
- elem->SetDoubleAttribute("QR", orientation[3]);
-
- elem->SetDoubleAttribute("C00", matrix[0][0]);
- elem->SetDoubleAttribute("C01", matrix[0][1]);
- elem->SetDoubleAttribute("C02", matrix[0][2]);
- elem->SetDoubleAttribute("C03", matrix[0][3]);
- elem->SetDoubleAttribute("C04", matrix[0][4]);
- elem->SetDoubleAttribute("C05", matrix[0][5]);
- elem->SetDoubleAttribute("C10", matrix[1][0]);
- elem->SetDoubleAttribute("C11", matrix[1][1]);
- elem->SetDoubleAttribute("C12", matrix[1][2]);
- elem->SetDoubleAttribute("C13", matrix[1][3]);
- elem->SetDoubleAttribute("C14", matrix[1][4]);
- elem->SetDoubleAttribute("C15", matrix[1][5]);
+ elem->SetAttribute("Type", m_Type.c_str());
+ elem->SetAttribute("Time", timestamp);
+ elem->SetAttribute("X", position[0]);
+ elem->SetAttribute("Y", position[1]);
+ elem->SetAttribute("Z", position[2]);
+
+ elem->SetAttribute("QX", orientation[0]);
+ elem->SetAttribute("QY", orientation[1]);
+ elem->SetAttribute("QZ", orientation[2]);
+ elem->SetAttribute("QR", orientation[3]);
+
+ elem->SetAttribute("C00", matrix[0][0]);
+ elem->SetAttribute("C01", matrix[0][1]);
+ elem->SetAttribute("C02", matrix[0][2]);
+ elem->SetAttribute("C03", matrix[0][3]);
+ elem->SetAttribute("C04", matrix[0][4]);
+ elem->SetAttribute("C05", matrix[0][5]);
+ elem->SetAttribute("C10", matrix[1][0]);
+ elem->SetAttribute("C11", matrix[1][1]);
+ elem->SetAttribute("C12", matrix[1][2]);
+ elem->SetAttribute("C13", matrix[1][3]);
+ elem->SetAttribute("C14", matrix[1][4]);
+ elem->SetAttribute("C15", matrix[1][5]);
if (dataValid)
elem->SetAttribute("Valid",1);
else
elem->SetAttribute("Valid",0);
if (hasOrientation)
elem->SetAttribute("hO",1);
else
elem->SetAttribute("hO",0);
if (hasPosition)
elem->SetAttribute("hP",1);
else
elem->SetAttribute("hP",0);
}
- void mitk::Transform::FromXML(TiXmlElement* elem)
+ void mitk::Transform::FromXML(const tinyxml2::XMLElement* elem)
{
assert(elem);
mitk::NavigationData::Pointer nd = mitk::NavigationData::New();
mitk::NavigationData::PositionType position;
mitk::NavigationData::OrientationType orientation(0.0,0.0,0.0,0.0);
mitk::NavigationData::TimeStampType timestamp = -1;
mitk::NavigationData::CovarianceMatrixType matrix;
bool hasPosition = true;
bool hasOrientation = true;
bool dataValid = false;
position.Fill(0.0);
matrix.SetIdentity();
- std::string type = Transform::UNKNOWN_TYPE;
- elem->QueryStringAttribute("Type", &type);
+ const char* typeC = elem->Attribute("Type");
+ std::string type = nullptr == typeC
+ ? Transform::UNKNOWN_TYPE
+ : typeC;
+
elem->QueryDoubleAttribute("Time",×tamp);
// position and orientation is mandatory!
- if(elem->QueryDoubleAttribute("X", &position[0]) != TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("X", &position[0]) != tinyxml2::XML_SUCCESS)
throw std::invalid_argument("No X position found in xml");
- if(elem->QueryDoubleAttribute("Y", &position[1]) != TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("Y", &position[1]) != tinyxml2::XML_SUCCESS)
throw std::invalid_argument("No Y position found in xml");
- if(elem->QueryDoubleAttribute("Z", &position[2]) != TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("Z", &position[2]) != tinyxml2::XML_SUCCESS)
throw std::invalid_argument("No Z position found in xml");
- if(elem->QueryDoubleAttribute("QX", &orientation[0]) != TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("QX", &orientation[0]) != tinyxml2::XML_SUCCESS)
throw std::invalid_argument("No QX orientation found in xml");
- if(elem->QueryDoubleAttribute("QY", &orientation[1]) != TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("QY", &orientation[1]) != tinyxml2::XML_SUCCESS)
throw std::invalid_argument("No QY orientation found in xml");
- if(elem->QueryDoubleAttribute("QZ", &orientation[2]) != TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("QZ", &orientation[2]) != tinyxml2::XML_SUCCESS)
throw std::invalid_argument("No QZ orientation found in xml");
- if(elem->QueryDoubleAttribute("QR", &orientation[3]) != TIXML_SUCCESS)
+ if(elem->QueryDoubleAttribute("QR", &orientation[3]) != tinyxml2::XML_SUCCESS)
throw std::invalid_argument("No QR orientation found in xml");
elem->QueryDoubleAttribute("C00", &matrix[0][0]);
elem->QueryDoubleAttribute("C01", &matrix[0][1]);
elem->QueryDoubleAttribute("C02", &matrix[0][2]);
elem->QueryDoubleAttribute("C03", &matrix[0][3]);
elem->QueryDoubleAttribute("C04", &matrix[0][4]);
elem->QueryDoubleAttribute("C05", &matrix[0][5]);
elem->QueryDoubleAttribute("C10", &matrix[1][0]);
elem->QueryDoubleAttribute("C11", &matrix[1][1]);
elem->QueryDoubleAttribute("C12", &matrix[1][2]);
elem->QueryDoubleAttribute("C13", &matrix[1][3]);
elem->QueryDoubleAttribute("C14", &matrix[1][4]);
elem->QueryDoubleAttribute("C15", &matrix[1][5]);
int tmpval = 0;
elem->QueryIntAttribute("Valid", &tmpval);
if (tmpval == 0)
dataValid = false;
else
dataValid = true;
tmpval = 0;
elem->QueryIntAttribute("hO", &tmpval);
if (tmpval == 0)
hasOrientation = false;
else
hasOrientation = true;
tmpval = 0;
elem->QueryIntAttribute("hP", &tmpval);
if (tmpval == 0)
hasPosition = false;
else
hasPosition = true;
nd->SetIGTTimeStamp(timestamp);
nd->SetPosition(position);
nd->SetOrientation(orientation);
nd->SetCovErrorMatrix(matrix);
nd->SetDataValid(dataValid);
nd->SetHasOrientation(hasOrientation);
nd->SetHasPosition(hasPosition);
m_NavData = nd;
m_Type = type;
this->Modified();
}
} // namespace mitk
std::ostream& operator<< (std::ostream& os, mitk::Transform::Pointer p)
{
os << p->ToString();
return os;
}
diff --git a/Modules/CameraCalibration/mitkTransform.h b/Modules/CameraCalibration/mitkTransform.h
index 233abbc5b2..7aeabdd4b5 100644
--- a/Modules/CameraCalibration/mitkTransform.h
+++ b/Modules/CameraCalibration/mitkTransform.h
@@ -1,301 +1,300 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#ifndef MITKTRANSFORM_H
#define MITKTRANSFORM_H
#include
#include
#include
#include
#include
-#include
#include
#include
#include
#include
namespace mitk {
///
/// \brief class representing a transfrom in 3D
///
/// internally it stores a mitk navigation data. this is more
/// or less a wrapper for navigation data for easy casting
/// between opencv/vnl/mitk/xml representations of transform
/// data
///
class MITKCAMERACALIBRATION_EXPORT Transform: public itk::Object,
public XMLSerializable
{
public:
mitkClassMacroItkParent(Transform, itk::Object);
itkFactorylessNewMacro(Transform);
mitkNewMacro1Param(Transform, const mitk::NavigationData*);
mitkNewMacro1Param(Transform, const std::string&);
///
/// constants describing the type of transform
/// represented here
///
static const std::string UNKNOWN_TYPE;
static const std::string ENDOSCOPE_SCOPE_TOOL;
static const std::string ENDOSCOPE_CAM_TOOL;
static const std::string CHESSBOARD_TOOL;
static const std::string POINTER_TOOL;
static const std::string POINTER_TO_CHESSBOARD_ORIGIN;
static const std::string POINTER_TO_CHESSBOARD_X_SUPPORT_POINT;
static const std::string POINTER_TO_CHESSBOARD_Y_SUPPORT_POINT;
static const std::string BOARD_TO_BOARD_TOOL;
static const std::string REFERENCE_CAMERA_TRANSFORM;
static const std::string REFERENCE_SCOPE_TRANSFORM;
static const std::string EYE_TO_HAND_TRANSFORM;
static const std::string CAMERA_EXTRINSICS;
itkGetConstMacro(Type, std::string);
itkSetMacro(Type, std::string&);
///
/// Copies the content of transform to this
/// instance
///
void Copy( const mitk::Transform* transform );
///
/// Copies the content of transform to this
/// instance
///
void Copy( const mitk::NavigationData* transform );
///
/// Inverts the rotation of this transform
/// (Polaris navigation Data have inverted rotation
/// so you may want to call this function when using
/// polaris data)
///
void TransposeRotation();
///
/// get a copy of this transform
///
mitk::Transform::Pointer Clone() const;
///
/// concatenate this transform with the given one,
/// i.e. this transform is done first, then transform
/// ( if x is this transform, y is transform, then this will be y*x)
/// post multiply semantics!
/// \see vtkTransform
///
void Concatenate( mitk::Transform* transform );
///
/// same as above with vnl mat argument
///
void Concatenate( const vnl_matrix_fixed& transform );
///
/// same as above with vtk mat argument
///
void Concatenate( const vtkMatrix4x4* transform );
///
/// invert this transform
///
void Invert();
///
/// resets the internal variables except type
///
void Reset();
///
/// read from xml
///
- void FromXML(TiXmlElement* elem) override;
+ void FromXML(const tinyxml2::XMLElement* elem) override;
///
/// read csv file
///
void FromCSVFile(const std::string& file);
///
/// grafts the data from naviData to this transform
///
void SetNavigationData( const mitk::NavigationData* naviData );
///
/// method to set orientation quat
///
void SetOrientation( const vnl_quaternion& orientation);
///
/// method to set float valued orientation quat
///
void SetOrientation( const vnl_quaternion& orientation);
///
/// method to set translation
///
void SetTranslation( const vnl_vector_fixed& transl);
///
/// method to set a vector of doubles as translation
///
void SetTranslation( const vnl_vector& transl);
///
/// method to set a mitk::Point3D as position
///
void SetPosition( const mitk::Point3D& transl);
///
/// sets rotation with a rotation matrix
///
void SetRotation( vnl_matrix_fixed& mat);
///
/// sets rotation with a non fixed rotation matrix
///
void SetRotation( vnl_matrix& mat);
///
/// sets rotation and translation with a transformation matrix
///
void SetMatrix( const vnl_matrix_fixed& mat);
///
/// sets rotation and translation with a vtk transformation matrix
///
void SetMatrix( const vtkMatrix4x4* mat);
///
/// sets translation from a POD vector
///
void SetTranslation( float* array );
///
/// sets translation from a POD vector. this must be a
/// 3x3=9 sized vector in row major format (first row = first
/// three elements)
///
void SetRotation( float* array );
///
/// sets translation from a POD vector
///
void SetTranslation( double array[3] );
///
/// sets translation from a POD vector
///
void SetRotation( double array[3][3] );
///
/// method to set translation by cv vector
///
void SetTranslation( const cv::Mat& transl);
///
/// sets rotation with a rotation matrix
///
void SetRotation( const cv::Mat& mat );
///
/// sets rotation with a rodrigues rotation vector
///
void SetRotationVector( const cv::Mat& rotVec);
///
/// \return the navigation data that stores all information
///
mitk::NavigationData::Pointer GetNavigationData() const;
///
/// calls navigationdata::GetPosition()
///
mitk::Point3D GetPosition() const;
///
/// same as GetPosition
///
mitk::Point3D GetTranslation() const;
///
/// calls navigationdata::IsValid()
///
bool IsValid() const;
///
/// calls navigationdata::SetValid()
///
void SetValid(bool valid);
///
/// calls navigationdata::GetOrientation()
///
mitk::Quaternion GetOrientation() const;
///
/// \return the homogeneous matrix representing this transform
///
vnl_matrix_fixed GetMatrix() const;
///
/// \return the homogeneous vtk matrix representing this transform
///
void GetMatrix(vtkMatrix4x4* matrix) const;
///
/// \return the homogeneous vtk matrix representing this transform
/// in !OpenGL! left handed coordinate system
///
void GetVtkOpenGlMatrix(vtkMatrix4x4* matrix) const;
mitk::Point3D TransformPoint(mitk::Point3D point) const;
///
/// create xml representation
///
- void ToXML(TiXmlElement* elem) const override;
+ void ToXML(tinyxml2::XMLElement* elem) const override;
///
/// create string representation
///
std::string ToString() const;
///
/// create string csv representation (only the transformation values!!!!)
///
std::string ToCSVString() const;
///
/// create matlab representation
///
std::string ToMatlabString(const std::string& varname="transform",
bool printLastRow=true) const;
///
/// write csv representation to file (only the transformation values!!!!)
///
void ToCSVFile(const std::string& file) const;
///
/// write matlab representation to file
///
void ToMatlabFile(const std::string& file
, const std::string& varname="transform") const;
///
/// conversion to cv types
///
cv::Mat GetCvTranslation() const;
cv::Mat GetCvRotationVector() const;
cv::Mat GetCvRotationMatrix() const;
cv::Mat GetCvMatrix() const;
///
/// conversion to vnl types
///
vnl_vector_fixed GetVnlTranslation() const;
vnl_vector_fixed GetVnlDoubleTranslation() const;
vnl_quaternion GetVnlDoubleQuaternion() const;
vnl_matrix_fixed GetVnlRotationMatrix() const;
vnl_matrix_fixed GetVnlDoubleMatrix() const;
protected:
Transform();
Transform(const mitk::NavigationData* nd);
Transform(const std::string& s);
// everything is stored here
mitk::NavigationData::Pointer m_NavData;
///
/// saves the type of the transform (Default is UNKNOWN_TYPE)
///
std::string m_Type;
};
} // namespace mitk
MITKCAMERACALIBRATION_EXPORT std::ostream& operator<<
(std::ostream& os, mitk::Transform::Pointer p);
#endif // MITKTRANSFORM_H
diff --git a/Modules/CameraCalibration/mitkXMLSerializable.cpp b/Modules/CameraCalibration/mitkXMLSerializable.cpp
index 525f8456de..0479a46ab1 100644
--- a/Modules/CameraCalibration/mitkXMLSerializable.cpp
+++ b/Modules/CameraCalibration/mitkXMLSerializable.cpp
@@ -1,137 +1,137 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include
#include "mitkEndoDebug.h"
#include "mitkEndoMacros.h"
#include
+#include
namespace mitk
{
const std::string XMLSerializable::FILE_REFERENCE_ATTRIBUTE_NAME = "fileRef";
const std::string XMLSerializable::ROOT_NAME = "data";
void mitk::XMLSerializable::ToXMLFile(const std::string& file
, const std::string& elemName)
{
- TiXmlElement * rootElem=nullptr;
- TiXmlElement * element=nullptr;
+ tinyxml2::XMLElement * rootElem=nullptr;
+ tinyxml2::XMLElement* element=nullptr;
// determine element to write to
std::string elementName = elemName;
if(elementName.empty())
elementName = this->GetNameOfClass();
- TiXmlDocument doc( file.c_str() );
- bool loadOkay = doc.LoadFile();
+ tinyxml2::XMLDocument doc;
// if the document already exists ...
- if(loadOkay)
+ if(tinyxml2::XML_SUCCESS == doc.LoadFile(file.c_str()))
{
// try to identify the XML element of this class as the root
// or as the child of the root
rootElem = doc.RootElement();
endoAssertMsg( rootElem, "No root element found in " << file );
// if root element represents this element remove the root
- if( rootElem->ValueStr() == elementName )
+ if( std::string(rootElem->Value() != nullptr ? rootElem->Value() : "") == elementName )
{
- doc.RemoveChild(rootElem);
+ doc.DeleteChild(rootElem);
rootElem = nullptr;
}
else
{
// if it is a child of the root remove it too
- element = rootElem->FirstChildElement(elementName);
+ element = rootElem->FirstChildElement(elementName.c_str());
if(element)
- rootElem->RemoveChild(element);
+ rootElem->DeleteChild(element);
}
}
else
{
// document did not exist, create new one with declration
- auto decl = new TiXmlDeclaration( "1.0", "", "" );
- doc.LinkEndChild( decl );
+ doc.InsertEndChild( doc.NewDeclaration() );
}
m_XMLFileName = file;
// create element (if the document already exists this element was removed)
- element = new TiXmlElement( elementName );
+ element = doc.NewElement( elementName.c_str() );
this->ToXML( element );
// if we do not have a root element create a new one
if(!rootElem)
- rootElem = new TiXmlElement( ROOT_NAME );
+ rootElem = doc.NewElement( ROOT_NAME.c_str() );
// add the element node as child
- rootElem->LinkEndChild(element);
+ rootElem->InsertEndChild(element);
// if no root element exists, add it now
if(doc.RootElement() == nullptr)
- doc.LinkEndChild( rootElem );
+ doc.InsertEndChild( rootElem );
- if(!doc.SaveFile( file ))
+ if(tinyxml2::XML_SUCCESS != doc.SaveFile( file.c_str() ))
{
std::ostringstream s; s << "File " << file
<< " could not be written. Please check permissions.";
throw std::logic_error(s.str());
}
}
std::string mitk::XMLSerializable::GetXMLFileName() const
{
return m_XMLFileName;
}
void mitk::XMLSerializable::FromXMLFile(const std::string& file
, const std::string& elemName)
{
endodebug( "Trying to read from " << file )
- TiXmlDocument doc( file.c_str() );
- bool loadOkay = doc.LoadFile();
- if(!loadOkay)
+ tinyxml2::XMLDocument doc;
+ if(tinyxml2::XML_SUCCESS != doc.LoadFile(file.c_str()))
{
std::ostringstream s; s << "File " << file
<< " could not be loaded!";
throw std::logic_error(s.str().c_str());
}
m_XMLFileName = file;
- TiXmlElement* elem = doc.FirstChildElement();
+ auto* elem = doc.FirstChildElement();
endoAssertMsg( elem, "No root element found" );
// determine element to read from
std::string elementName = elemName;
if(elementName.empty())
elementName = this->GetNameOfClass();
// try again with the first element
if(strcmp(elem->Value(), elementName.c_str()) != 0)
elem = elem->FirstChildElement(elementName.c_str());
endoAssertMsg( elem, "No child element \"" << elementName <<
"\" found in " << file );
// if theres an attribute as file reference try to load the class
// from that file
- std::string filename;
- if(elem->QueryStringAttribute(FILE_REFERENCE_ATTRIBUTE_NAME.c_str(), &filename)
- == TIXML_SUCCESS)
+ const char* filenameC = elem->Attribute(FILE_REFERENCE_ATTRIBUTE_NAME.c_str());
+ std::string filename = nullptr != filenameC
+ ? filenameC
+ : "";
+ if(!filename.empty())
{
if( !itksys::SystemTools::FileIsFullPath(filename.c_str()) )
filename = itksys::SystemTools::GetFilenamePath(file) + "/" + filename;
this->FromXMLFile(filename);
return; // exit!
}
this->FromXML( elem );
}
}
diff --git a/Modules/CameraCalibration/mitkXMLSerializable.h b/Modules/CameraCalibration/mitkXMLSerializable.h
index 31dc61d346..8c0d78ecb9 100644
--- a/Modules/CameraCalibration/mitkXMLSerializable.h
+++ b/Modules/CameraCalibration/mitkXMLSerializable.h
@@ -1,88 +1,92 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#ifndef MITKXMLSerializable_H
#define MITKXMLSerializable_H
#include
-#include
#include
#include
#include
+namespace tinyxml2
+{
+ class XMLElement;
+}
+
namespace mitk
{
///
/// \brief interface for all classes able to write themselves to XML files
///
class MITKCAMERACALIBRATION_EXPORT XMLSerializable
{
public:
///
/// value of the special tag for file references
/// if this is attribute is found the class
/// will be loaded from the file in the attributes value
///
static const std::string FILE_REFERENCE_ATTRIBUTE_NAME;
///
/// the name of the root node that is created when the element is saved
///
static const std::string ROOT_NAME;
///
/// the tag value will be equals to the class name (function
/// implemented by the itkTypeMacro)
///
virtual const char* GetNameOfClass() const = 0;
///
/// write your values here to elem
///
- virtual void ToXML(TiXmlElement* elem) const = 0;
+ virtual void ToXML(tinyxml2::XMLElement* elem) const = 0;
///
/// read your values here from elem
///
- virtual void FromXML(TiXmlElement* elem) = 0;
+ virtual void FromXML(const tinyxml2::XMLElement* elem) = 0;
///
/// tries to write the xml data obtained in ToXML() to file
///
virtual void ToXMLFile(const std::string& file
, const std::string& elemName="");
///
/// loads the XML file and calls FromXML()
/// takes the first child of the document
/// if this root node value is not equal to GetNameOfClass()
/// the method will try to find the first children of the root
/// node with the value of GetNameOfClass()
/// if elemName is not empty then this value will be used instead
/// of GetNameOfClass()
/// if this node is found it will check if an attribute named
/// FILE_REFERENCE_ATTRIBUTE_NAME is found: in this case
/// the method calls itself with this attributes value as parameter
///
virtual void FromXMLFile(const std::string& file
, const std::string& elemName="");
///
/// \see m_XMLFileName
///
std::string GetXMLFileName() const;
private:
///
/// saves the xmlfile name set for this serializable ( in FromXMLFile() )
///
std::string m_XMLFileName;
};
}
#endif
diff --git a/Modules/Classification/CLUtilities/CMakeLists.txt b/Modules/Classification/CLUtilities/CMakeLists.txt
index 3c7f86a35d..0d441525b8 100644
--- a/Modules/Classification/CLUtilities/CMakeLists.txt
+++ b/Modules/Classification/CLUtilities/CMakeLists.txt
@@ -1,14 +1,14 @@
mitk_create_module(
DEPENDS MitkCore MitkCLCore MitkCommandLine MitkDICOM
- PACKAGE_DEPENDS PUBLIC Eigen PRIVATE tinyxml VTK|FiltersStatistics
+ PACKAGE_DEPENDS PUBLIC Eigen PRIVATE tinyxml2|tinyxml2 VTK|FiltersStatistics
)
if(TARGET ${MODULE_TARGET})
if(MITK_USE_OpenMP)
- target_link_libraries(${MODULE_TARGET} PUBLIC OpenMP::OpenMP_CXX)
+ target_link_libraries(${MODULE_TARGET} PUBLIC OpenMP::OpenMP_CXX PRIVATE tinyxml2::tinyxml2)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()
endif()
diff --git a/Modules/Classification/CLUtilities/src/mitkCLResultXMLWriter.cpp b/Modules/Classification/CLUtilities/src/mitkCLResultXMLWriter.cpp
index 0d3bf0c5ef..c884a41381 100644
--- a/Modules/Classification/CLUtilities/src/mitkCLResultXMLWriter.cpp
+++ b/Modules/Classification/CLUtilities/src/mitkCLResultXMLWriter.cpp
@@ -1,318 +1,321 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include
#include
#include
#include
#include