-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: Interpretation of the Euler angles ZYX or ZXY was not exported.
The flag indicating whether the Euler angles should be composed in ZYX or ZXY order was not part of the fixed parameters as it should have been. This patch adds it to the fixed parameters. This was an issue with serialization de-serialization of the transform. The choice of composition method was not serialized and writing followed by reading changed the transform. Change-Id: I0a2230022c35b8a7ef2c5c4d91e7aabfa50b9d7c
- Loading branch information
Showing
6 changed files
with
219 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
itk_module_test() | ||
set(ITKIOTransformInsightLegacyTests | ||
itkIOTransformTxtTest.cxx | ||
itkIOEuler3DTransformTxtTest.cxx | ||
) | ||
|
||
CreateTestDriver(ITKIOTransformInsightLegacy "${ITKIOTransformInsightLegacy-Test_LIBRARIES}" "${ITKIOTransformInsightLegacyTests}") | ||
|
||
itk_add_test(NAME itkIOTransformTxtTest | ||
COMMAND ITKIOTransformInsightLegacyTestDriver itkIOTransformTxtTest | ||
${ITK_TEST_OUTPUT_DIR} ) | ||
|
||
itk_add_test(NAME itkIOTransformEuler3DTxtTest | ||
COMMAND ITKIOTransformInsightLegacyTestDriver itkIOEuler3DTransformTxtTest | ||
DATA{Input/euler3DOldFormat.tfm} ${ITK_TEST_OUTPUT_DIR}/euler3DNewFormat.tfm) |
1 change: 1 addition & 0 deletions
1
Modules/IO/TransformInsightLegacy/test/Input/euler3DOldFormat.tfm.md5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
29469c3fbf3328d149fee08294b32df1 |
83 changes: 83 additions & 0 deletions
83
Modules/IO/TransformInsightLegacy/test/itkIOEuler3DTransformTxtTest.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/*========================================================================= | ||
* | ||
* Copyright Insight Software Consortium | ||
* | ||
* 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.txt | ||
* | ||
* 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. | ||
* | ||
*=========================================================================*/ | ||
|
||
#include "itkTransformFileWriter.h" | ||
#include "itkTransformFileReader.h" | ||
#include "itkTransformFactory.h" | ||
#include "itkTxtTransformIOFactory.h" | ||
#include "itkEuler3DTransform.h" | ||
#include "itkMath.h" | ||
|
||
int itkIOEuler3DTransformTxtTest(int argc, char *argv[]) | ||
{ | ||
if( argc != 3 ) | ||
{ | ||
std::cerr<< "Usage: " | ||
<< argv[0] | ||
<<" inputFileName outputFileName" | ||
<< std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
itk::ObjectFactoryBase::RegisterFactory(itk::TxtTransformIOFactory::New() ); | ||
|
||
typedef itk::Euler3DTransform<double> TransformType; | ||
TransformType::Pointer oldStyleInput, newStyleInput; | ||
|
||
typedef itk::TransformFileReaderTemplate<double> ReaderType; | ||
ReaderType::Pointer reader = ReaderType::New(); | ||
|
||
typedef itk::TransformFileWriterTemplate<double> WriterType; | ||
WriterType::Pointer writer = WriterType::New(); | ||
|
||
//read old style format in | ||
reader->SetFileName( argv[1] ); | ||
reader->Update(); | ||
oldStyleInput = static_cast< TransformType* >(( reader->GetTransformList()->begin() )->GetPointer()); | ||
|
||
//modify the interpretation of the Euler angles | ||
oldStyleInput->SetComputeZYX( true ); | ||
|
||
//write in new style format | ||
writer->SetFileName( argv[2] ); | ||
writer->SetInput( oldStyleInput ); | ||
writer->Update(); | ||
|
||
//read new style format back in | ||
reader->SetFileName( argv[2] ); | ||
reader->Update(); | ||
newStyleInput = static_cast< TransformType* >(( reader->GetTransformList()->begin() )->GetPointer()); | ||
|
||
const TransformType::MatrixType &oldStyleMat = oldStyleInput->GetMatrix(); | ||
const TransformType::MatrixType &newStyleMat = newStyleInput->GetMatrix(); | ||
|
||
if(!(itk::Math::FloatAlmostEqual(oldStyleMat(0,0), newStyleMat(0,0)) && | ||
itk::Math::FloatAlmostEqual(oldStyleMat(0,1), newStyleMat(0,1)) && | ||
itk::Math::FloatAlmostEqual(oldStyleMat(0,2), newStyleMat(0,2)) && | ||
itk::Math::FloatAlmostEqual(oldStyleMat(1,0), newStyleMat(1,0)) && | ||
itk::Math::FloatAlmostEqual(oldStyleMat(1,1), newStyleMat(1,1)) && | ||
itk::Math::FloatAlmostEqual(oldStyleMat(1,2), newStyleMat(1,2)) && | ||
itk::Math::FloatAlmostEqual(oldStyleMat(2,0), newStyleMat(2,0)) && | ||
itk::Math::FloatAlmostEqual(oldStyleMat(2,1), newStyleMat(2,1)) && | ||
itk::Math::FloatAlmostEqual(oldStyleMat(2,2), newStyleMat(2,2)))) | ||
{ | ||
std::cerr<< "Error reading new style format, different from data in memory." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
return EXIT_SUCCESS; | ||
} |