diff --git a/Core/Code/DataManagement/mitkTypes.h b/Core/Code/DataManagement/mitkTypes.h index 41852f85b3..504cf340b6 100644 --- a/Core/Code/DataManagement/mitkTypes.h +++ b/Core/Code/DataManagement/mitkTypes.h @@ -1,66 +1,67 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKVECTOR_H_HEADER_INCLUDED_C1EBD0AD #define MITKVECTOR_H_HEADER_INCLUDED_C1EBD0AD #include "mitkConstants.h" #include "mitkQuaternion.h" #include "mitkPoint.h" #include "mitkVector.h" #include "mitkMatrix.h" #include "mitkEqual.h" // this include hold the old deprecated ways to convert from itk 2 vtk and the likes. +// th calls to these functions shall be removed in future bugsquashings so that this include can be removed. #include "mitkVectorDeprecated.h" /* * This part of the code has been shifted here to avoid compiler clashes * caused by including before the declaration of * the Equal() methods above. This problem occurs when using MSVC and is * probably related to a compiler bug. */ #include namespace mitk { typedef itk::AffineGeometryFrame::TransformType AffineTransform3D; } #define mitkSetConstReferenceMacro(name,type) \ virtual void Set##name (const type & _arg) \ { \ itkDebugMacro("setting " << #name " to " << _arg ); \ if (this->m_##name != _arg) \ { \ this->m_##name = _arg; \ this->Modified(); \ } \ } #define mitkSetVectorMacro(name,type) \ mitkSetConstReferenceMacro(name,type) #define mitkGetVectorMacro(name,type) \ itkGetConstReferenceMacro(name,type) #endif /* MITKVECTOR_H_HEADER_INCLUDED_C1EBD0AD */ diff --git a/Core/Documentation/Doxygen/Concepts/BasicDataTypes.dox b/Core/Documentation/Doxygen/Concepts/BasicDataTypes.dox new file mode 100644 index 0000000000..3f9524a24c --- /dev/null +++ b/Core/Documentation/Doxygen/Concepts/BasicDataTypes.dox @@ -0,0 +1,59 @@ +/** +\page BasicDataTypesPage Low level data types in MITK and their usage. + +This page describes how to use very foundational data-tyes in mitk like mitk::Vector, mitk::Point and mitk::Matrix and +how they can interact. + +\tableofcontents + +\section Structure + +The previously known, monolythic structure of putting every basic type into mitkVector.h has been broken and +mitkVector.h has been split up into several, more atomic files, namely: + +-# mitkConstants.h : contains basic constants like mitk::ScalarType or mitk::eps +-# mitkArray.h : copy from and to types which implement the [] operator, like e.g. Plain Old Datatypes (POD) or the opencv vector +-# mitkPoint.h : the mitk::Point class. This is basically the itk::Point with the added ToArray and FromArray members to conveniently copy from and to ArrayTypes. +-# mitkVector.h : the mitk::Vector class. This is an itk::Vector, but with the possiblity to implicicly convert to vnl_vector and vnl_vector_fixed +-# mitkMatrix.h : the mitk::Matrix class. This is an itk::Matrix with the added ToArray and FromArray members to conveniently copy from and to ArrayTypes. +-# mitkQuaternion.h : a typedef to vnl_quaternion. +-# mitkTypes.h : this file includes all of the above as a convenience header + +The Equal methods to compare Points, Vectors, Matrices, ... have been moved into the respective files. +E.g., if you want to compare two vectors simply use the Equal method provided by mitkVector.h. + +\section Conversion between the data-types + +If you want to convert a mitk::Vector from or to a vnl_vector or a vnl_vector_fixed, simply write + +\code + mitkVector3D = vnlVector3D; + vnlVector3D_2 = mitkVector3D; +\endcode + +Unfortunately this mechanism couldn't be implemented to every type of conversion. But in any case, the ToArray and FromArray member +functions can be used to convert to types which have the []-operator implemented. E.g., + +\code + cv::Vec3d cvVec3D; + + mitkVector3D.ToArray(cvVec3D); + mitkVector3D_2.FromArray(cvVec3D); +\endcode + +Unfortunately, no implicic conversion from mitk::Point to mitk::Vector could be implemented, as this would break with itk's +concept of separating points and vectors. If you want to convert, use: + +\code + mitkVector3D = mitkPoint3D.GetVectorFromOrigin(); + mitkPoint3D_2 = mitkVector3D; +\endcode + +more examples of how to convert between data types can be found in the tests: + +-# mitkArrayTypeConversionTest.cpp +-# mitkPointTypeConversionTest.cpp +-# mitkVectorTypeConversionTest.cpp +-# mitkMatrixTypeConversionTest.cpp + +*/ \ No newline at end of file