OpenWalnut  1.5.0dev
WCoordConverter.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <memory>
26 #include <utility>
27 
28 #include "WCoordConverter.h"
29 #include "core/common/WBoundingBox.h"
30 #include "core/common/math/WLinearAlgebraFunctions.h"
31 
32 
34  m_rotMat( rotMat ),
35  m_origin( origin ),
36  m_scale( scale ),
37  m_coordinateSystemMode( CS_WORLD )
38 {
39 }
40 
42 {
43 }
44 
46 {
47  WVector3d out( in );
48  return out;
49 }
50 
52 {
53  return m_boundingBox;
54 }
55 
57 {
58  m_boundingBox = boundingBox;
59 }
60 
62 {
63  WVector3d r( transformPosition3DWithMatrix4D( m_rotMat, point ) );
64  return r;
65 }
66 
67 void WCoordConverter::setCoordinateSystemMode( coordinateSystemMode mode )
68 {
70 }
71 
73 {
75 }
76 
78 {
79  switch( m_coordinateSystemMode )
80  {
81  case CS_WORLD:
82  return number;
83  break;
84  case CS_CANONICAL:
85  return static_cast<int>( m_boundingBox.xMax() - number );
86  break;
87  case CS_TALAIRACH:
88  {
89  WVector3d tmp( number, 0.0, 0.0 );
90  return static_cast<int>( w2t( tmp )[1] + 0.5 );
91  }
92  break;
93  default:
94  return number;
95  break;
96  }
97 }
98 
100 {
101  switch( m_coordinateSystemMode )
102  {
103  case CS_WORLD:
104  return number;
105  break;
106  case CS_CANONICAL:
107  return static_cast<int>( number - m_boundingBox.yMin() );
108  break;
109  case CS_TALAIRACH:
110  {
111  WVector3d tmp( 0.0, number, 0.0 );
112  return static_cast<int>( w2t( tmp )[0] + 0.5 );
113  }
114  break;
115  default:
116  return number;
117  break;
118  }
119 }
120 
122 {
123  switch( m_coordinateSystemMode )
124  {
125  case CS_WORLD:
126  return number;
127  break;
128  case CS_CANONICAL:
129  return static_cast<int>( number - m_boundingBox.zMin() );
130  break;
131  case CS_TALAIRACH:
132  {
133  WVector3d tmp( 0.0, 0.0, number );
134  return static_cast<int>( w2t( tmp )[2] + 0.5 );
135  }
136  break;
137  default:
138  return number;
139  break;
140  }
141 }
142 
143 void WCoordConverter::setTalairachConverter( std::shared_ptr<WTalairachConverter> tc )
144 {
146 }
147 
148 std::shared_ptr<WTalairachConverter> WCoordConverter::getTalairachConverter()
149 {
150  return m_talairachConverter;
151 }
152 
154 {
155  return WVector3d( in[1], m_boundingBox.xMax() - in[0], in[2] );
156 }
157 
159 {
160  return WVector3d( m_boundingBox.xMax() - in[1], in[0] , in[2] );
161 }
162 
163 
165 {
166  return m_talairachConverter->Canonical2Talairach( w2c( in ) );
167 }
168 
170 {
171  return c2w( m_talairachConverter->ACPC2Canonical( m_talairachConverter->Talairach2ACPC( in ) ) );
172 }
std::shared_ptr< WTalairachConverter > getTalairachConverter()
getter for the talairach converter pointer
WVector3d worldCoordTransformed(WPosition point)
Transforms world coordinates.
int numberToCsZ(int number)
converts a number on the z axis according to the currently selected coordinate system
WVector3d w2t(WVector3d in)
transforms a vector from the world coordinate system to the talairach system
WVector3d operator()(WVector3d in)
Operator ()
WMatrix< double > m_rotMat
the rotation matrix to use
WBoundingBox m_boundingBox
bounding box of the wholy volume as provided by the dataset
int numberToCsX(int number)
converts a number on the x axis according to the currently selected coordinate system
std::shared_ptr< WTalairachConverter > m_talairachConverter
pointer to talairach convert for easy access
void setBoundingBox(WBoundingBox boundingBox)
Sets the bounding box of the volume.
coordinateSystemMode getCoordinateSystemMode()
getter for coordinate system mode
WVector3d c2w(WVector3d in)
transforms a vector from the canonical to the world coordinate system system
WVector3d w2c(WVector3d in)
transforms a vector from the world coordinate system to the canonical system
void setTalairachConverter(std::shared_ptr< WTalairachConverter > tc)
setter for the talairach converter pointer
int numberToCsY(int number)
converts a number on the y axis according to the currently selected coordinate system
void setCoordinateSystemMode(coordinateSystemMode mode)
setter for coordinate system mode
WBoundingBox getBoundingBox()
Gets the bounding box.
WVector3d t2w(WVector3d in)
transforms a vector from the canonical system to the world coordinate system
coordinateSystemMode m_coordinateSystemMode
the currently selected coordinate system mode
WCoordConverter(WMatrix< double > rotMat, WVector3d origin=WVector3d(0, 0, 0), WVector3d scale=WVector3d(1.0, 1.0, 1.0))
standard constructor
virtual ~WCoordConverter()
destructor
This only is a 3d double vector.