imagemappinginformation.h 5.23 KB
Newer Older
1
2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Software Framework.
4
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
7
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
// 
schultezub's avatar
schultezub committed
11
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
12
// 
13
14
15
16
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
17
// 
18
19
20
21
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
22
23
24
// 
// ================================================================================================

schultezub's avatar
schultezub committed
25
26
27
#ifndef imagemapping_h__
#define imagemapping_h__

28
29
#include "cgt/matrix.h"
#include "cgt/vector.h"
30
31

#include "core/coreapi.h"
schultezub's avatar
schultezub committed
32
#include "core/tools/mapping.h"
schultezub's avatar
schultezub committed
33

schultezub's avatar
schultezub committed
34
namespace campvis {
schultezub's avatar
schultezub committed
35
36
37
38
39
40
41

    /**
     * Contains all necessary for mapping the image or image values.
     * 
     * \todo    Make a full list of fields that belong in this class. Then check
     *          which of them belong together and which are derived measures.
     */
42
    class CAMPVIS_CORE_API ImageMappingInformation {
schultezub's avatar
schultezub committed
43
44
    public:
        /**
45
         * Creates a new default ImageMappingInformation.
46
         * \param   size                    Image size (number of elements, redundant...)
47
48
49
         * \param   offset                  Position of LLF corner in world coordinates (mm)
         * \param   voxelSize               Voxel size in (mm)
         * \param   realWorldValueMapping   Linear mapping for mapping element values to real world values, defaults to identity.
schultezub's avatar
schultezub committed
50
         */
51
        ImageMappingInformation(
52
            const tgt::vec3& size, 
53
54
55
            const tgt::vec3& offset, 
            const tgt::vec3& voxelSize, 
            const LinearMapping<float>& realWorldValueMapping = LinearMapping<float>::identity);
schultezub's avatar
schultezub committed
56

57
58
59
60
61
62
63
64
65
66
67
        /**
         * Returns the position of LLF corner in world coordinates (mm).
         * \return  _offset
         */
        const tgt::vec3& getOffset() const;

        /**
         * Returns the voxel size in mm.
         * \return  _voxelSize
         */
        const tgt::vec3& getVoxelSize() const;
schultezub's avatar
schultezub committed
68

69
70
        /**
         * Gets the transformation matrix from texture to world coordinates.
71
         * \return  _textureToWorldTransformation
72
         */
schultezub's avatar
schultezub committed
73
        const tgt::mat4& getTextureToWorldMatrix() const;
74

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
        /**
         * Gets the transformation matrix from world to texture coordinates.
         * \return  _worldToTextureTransformation
         */
        const tgt::mat4& getWorldToTextureMatrix() const;

        /**
         * Gets the transformation matrix from voxel to world coordinates.
         * \return  _voxelToWorldTransformation
         */
        const tgt::mat4& getVoxelToWorldMatrix() const;

        /**
         * Gets the transformation matrix from world to voxel coordinates.
         * \return  _worldToVoxelTransformation
         */
        const tgt::mat4& getWorldToVoxelMatrix() const;

schultezub's avatar
schultezub committed
93
94
95
96
        /**
         * Get the real world value mapping.
         * \return  Linear mapping for mapping element values to real world values.
         */
97
        const LinearMapping<float>& getRealWorldMapping() const;
98
        
schultezub's avatar
schultezub committed
99
100
101
102
        /**
         * Set the real world value mapping.
         * \param   rwvm    Linear mapping for mapping element values to real world values.
         */
103
        void setRealWorldMapping(const LinearMapping<float>& rwvm);
schultezub's avatar
schultezub committed
104

105
106
107
108
109
110
        /**
         * Overloaded equal operator
         * \param   obj    Object to compare with.
         */
        bool operator==(const ImageMappingInformation& obj) const ;

schultezub's avatar
schultezub committed
111
    private:
112
113
114
        /**
         * Updates the X-to-Y matrices.
         */
115
        void updateMatrices();
116
117

        tgt::vec3 _size;                                ///< Image size (number of elements, redundant...)
118
119
120
121
        tgt::vec3 _offset;                              ///< Position of LLF corner in world coordinates (mm)
        tgt::vec3 _voxelSize;                           ///< Voxel size in (mm)

        LinearMapping<float> _realWorldValueMapping;     ///< Linear mapping for mapping element values to real world values
122

123
        tgt::mat4 _textureToWorldTransformation;        ///< Transformation matrix from texture to world coordinates
124
        tgt::mat4 _worldToTextureTransformation;        ///< Transformation matrix from world to texture coordinates
schultezub's avatar
schultezub committed
125

126
127
        tgt::mat4 _voxelToWorldTransformation;        ///< Transformation matrix from voxel to world coordinates
        tgt::mat4 _worldToVoxelTransformation;        ///< Transformation matrix from world to voxel coordinates
schultezub's avatar
schultezub committed
128
129
130
131
    };

}
#endif // imagemapping_h__