24.09., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

imagemappinginformation.h 5.75 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-2015, 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
    public:
44 45 46 47 48
        /**
         *  Default Mapping is for a 1x1 image with 1mm voxels at the origin
         */
        ImageMappingInformation();

schultezub's avatar
schultezub committed
49
        /**
50
         * Creates a new default ImageMappingInformation.
51
         * \param   size                    Image size (number of elements, redundant...)
52 53
         * \param   offset                  Position of LLF corner in world coordinates (mm)
         * \param   voxelSize               Voxel size in (mm)
54
         * \param   customTransformation    Additional custom transformation from voxel to world coordinates, defaults to identity.
schultezub's avatar
schultezub committed
55
         */
56
        ImageMappingInformation(
57 58 59
            const cgt::vec3& size, 
            const cgt::vec3& offset, 
            const cgt::vec3& voxelSize, 
60
            const cgt::mat4& customTransformation = cgt::mat4::identity);
schultezub's avatar
schultezub committed
61

62 63 64 65 66 67 68
        // We're ok with the default implementations so we are explicit about it
        ImageMappingInformation(const ImageMappingInformation&) = default;
        ImageMappingInformation(ImageMappingInformation&&) = default;
        ImageMappingInformation& operator= (const ImageMappingInformation&) = default;
        ImageMappingInformation& operator= (ImageMappingInformation&&) = default;
        ~ImageMappingInformation() = default;

69 70 71 72
        /**
         * Returns the position of LLF corner in world coordinates (mm).
         * \return  _offset
         */
73
        const cgt::vec3& getOffset() const;
74 75 76 77 78

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

81 82 83 84 85 86
        /**
         * Returns the additional custom transformation from voxel to world coordinates.
         * \return  _customTransformation
         */
        const cgt::mat4 getCustomTransformation() const;

87 88
        /**
         * Gets the transformation matrix from texture to world coordinates.
89
         * \return  _textureToWorldTransformation
90
         */
91
        const cgt::mat4& getTextureToWorldMatrix() const;
92

93 94 95 96
        /**
         * Gets the transformation matrix from world to texture coordinates.
         * \return  _worldToTextureTransformation
         */
97
        const cgt::mat4& getWorldToTextureMatrix() const;
98 99 100 101 102

        /**
         * Gets the transformation matrix from voxel to world coordinates.
         * \return  _voxelToWorldTransformation
         */
103
        const cgt::mat4& getVoxelToWorldMatrix() const;
104 105 106 107 108

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

111 112 113 114 115 116
        /**
         *  Returns the image size information, as specified in the constructor as the 
         *  number of voxels in each direction.
         */
        const cgt::vec3& getImageSize() const;

117 118 119 120 121 122
        /**
         * Overloaded equal operator
         * \param   obj    Object to compare with.
         */
        bool operator==(const ImageMappingInformation& obj) const ;

schultezub's avatar
schultezub committed
123
    private:
124 125 126
        /**
         * Updates the X-to-Y matrices.
         */
schultezub's avatar
schultezub committed
127
        void updateMatrices();
128

129 130 131
        cgt::vec3 _size;                                ///< Image size (number of elements, redundant...)
        cgt::vec3 _offset;                              ///< Position of LLF corner in world coordinates (mm)
        cgt::vec3 _voxelSize;                           ///< Voxel size in (mm)
132
        cgt::mat4 _customTransformation;                ///< Additional custom transformation from voxel to world coordinates
133

134 135
        cgt::mat4 _textureToWorldTransformation;        ///< Transformation matrix from texture to world coordinates
        cgt::mat4 _worldToTextureTransformation;        ///< Transformation matrix from world to texture coordinates
schultezub's avatar
schultezub committed
136

137 138
        cgt::mat4 _voxelToWorldTransformation;        ///< Transformation matrix from voxel to world coordinates
        cgt::mat4 _worldToVoxelTransformation;        ///< Transformation matrix from world to voxel coordinates
schultezub's avatar
schultezub committed
139 140 141 142
    };

}
#endif // imagemapping_h__