00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "mitkSurfaceIndexToWorldTransformFilter.h" 00019 00020 #include "vtkPoints.h" 00021 #include "vtkPolyData.h" 00022 00023 mitk::SurfaceIndexToWorldTransformFilter::SurfaceIndexToWorldTransformFilter() 00024 { 00025 } 00026 00027 mitk::SurfaceIndexToWorldTransformFilter::~SurfaceIndexToWorldTransformFilter() 00028 { 00029 } 00030 00031 void mitk::SurfaceIndexToWorldTransformFilter::GenerateData() 00032 { 00033 mitk::Surface* input = const_cast<mitk::Surface*>( this->GetInput()); 00034 mitk::Surface::Pointer output = this->GetOutput(); 00035 00036 mitk::Point3D current, transformed; 00037 vtkPoints* surfacePoints = vtkPoints::New(); 00038 vtkPoints* newSurfacePoints = vtkPoints::New(); 00039 int pointIter = 0; 00040 00041 surfacePoints = input->GetVtkPolyData()->GetPoints(); 00042 00043 while(pointIter != surfacePoints->GetNumberOfPoints()) 00044 { 00045 double* intermed = surfacePoints->GetPoint(pointIter); 00046 current[0] = intermed[0]; 00047 current[1] = intermed[1]; 00048 current[2] = intermed[2]; 00049 00050 input->GetGeometry()->IndexToWorld(current, transformed); 00051 newSurfacePoints->InsertPoint( pointIter, transformed[0], transformed[1], transformed[2] ); 00052 pointIter++; 00053 } 00054 00055 output->GetVtkPolyData()->SetPoints(newSurfacePoints); 00056 output->GetVtkPolyData()->SetPolys(input->GetVtkPolyData()->GetPolys()); 00057 output->GetGeometry()->SetIdentity(); 00058 output->Modified(); 00059 output->Update(); 00060 } 00061 00062