[Insight-users] (no subject)

martin.garcia@epfl.ch martin . garcia at epfl . ch
Mon, 26 Aug 2002 10:44:46 +0200


Hi,

I'm trying to introduce the itktovtk example in my vc++ 6 project and I get A 
problem with the linking part of the building.
My main application simply calls the constructor of vtkItkConnector as follows:


CVtkItkConnector* conect= new CVtkItkConnector(/*data*/);

Thanks for your help if you can help me.


Here is my file, the corresponding header and the error:

// VtkItkConnector.cpp: implementation of the CVtkItkConnector class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"

#include <itkCommand.h>
#include <itkImage.h>
#include <itkVTKImageImport.h>
#include <itkVTKImageExport.h>
#include <itkCurvatureFlowImageFilter.h>

#include "osirislight.h"
#include "VtkItkConnector.h"

#include "vtkImageData.h"
#include "vtkImageExport.h"
#include "vtkImageImport.h"
#include "vtkImageNoiseSource.h"
#include "vtkImageActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkImageShiftScale.h"



#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CVtkItkConnector::CVtkItkConnector(/*vtkImageData* data*/)
{
	/*m_pImageData=data;
	vtkImageExport* vtkExporter=vtkImageExport::New();
	vtkExporter->SetInput(m_pImageData);

	//VTK to ITK Pipeline connection
	typedef itk::Image<float,2> ImageType;
	typedef itk::VTKImageImport<ImageType> ImageImportType;
	//typedef itk::CurvatureFlowImageFilter<ImageType,ImageType> 
DenoiserType;

	
	ImageImportType::Pointer itkImporter = ImageImportType::New();
	ConnectPipelines(vtkExporter,itkImporter);*/


	//----------------------------------------------------------------------
--
  // VTK pipeline.
  //------------------------------------------------------------------------
  
  vtkImageNoiseSource* source = vtkImageNoiseSource::New(); //This is a test 
part that will be
  source->SetWholeExtent(0, 255, 0, 255, 0, 0);             //Replaced by 
another vtkImageData
  source->SetMinimum(0);                                    //later
  source->SetMaximum(1);
  
  vtkImageExport* vtkExporter = vtkImageExport::New();
  vtkExporter->SetInput(source->GetOutput());
  
  //------------------------------------------------------------------------
  // VTK to ITK pipeline connection.
  //------------------------------------------------------------------------
  
  typedef itk::Image<float, 2> ImageType;
  typedef itk::VTKImageImport<ImageType> ImageImportType;
  ImageImportType::Pointer itkImporter = ImageImportType::New();
  ConnectPipelines(vtkExporter, itkImporter);

  //------------------------------------------------------------------------
  // ITK pipeline.
  //------------------------------------------------------------------------
  
  typedef itk::CurvatureFlowImageFilter<ImageType, ImageType> DenoiserType;
  
  // Create the itk::CurvatureFlowImageFilter and connect it
  // to the itk::RandomImageSource.
  DenoiserType::Pointer denoiser = DenoiserType::New();
  denoiser->SetInput(itkImporter->GetOutput());
  denoiser->SetTimeStep(0.15);
  denoiser->SetNumberOfIterations(8);

  
  
  //------------------------------------------------------------------------
  // ITK to VTK pipeline connection.
  //------------------------------------------------------------------------
  
  typedef itk::VTKImageExport<ImageType> ImageExportType;
  
  // Create the itk::VTKImageExport instance and connect it to the
  // itk::CurvatureFlowImageFilter.
  ImageExportType::Pointer itkExporter = ImageExportType::New();
  itkExporter->SetInput(denoiser->GetOutput());
  
  // Create the vtkImageImport and connect it to the
  // itk::VTKImageExport instance.
  vtkImageImport* vtkImporter = vtkImageImport::New();  
  ConnectPipelines(itkExporter, vtkImporter);
  
  //------------------------------------------------------------------------
  // VTK pipeline.
  //------------------------------------------------------------------------
  
  // Create a vtkImageShiftScale to convert the floating point image
  // to an unsigned char image.  Connect it to the vtkImageImport
  // instance.
  vtkImageShiftScale* shifter = vtkImageShiftScale::New();
  shifter->SetInput(vtkImporter->GetOutput());
  shifter->SetScale(256);
  shifter->SetOutputScalarTypeToUnsignedChar();

  // Create a vtkImageActor to help render the image.  Connect it to
  // the vtkImageShiftScale instance.
  vtkImageActor* actor = vtkImageActor::New();
  actor->SetInput(shifter->GetOutput());
  
  // Create a renderer, render window, and render window interactor to
  // display the results.
  vtkRenderer* renderer = vtkRenderer::New();
  vtkRenderWindow* renWin = vtkRenderWindow::New();
  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
  
  renWin->SetSize(500, 500);
  renWin->AddRenderer(renderer);
  iren->SetRenderWindow(renWin);
  
  // Add the vtkImageActor to the renderer for display.
  renderer->AddActor(actor);
  renderer->SetBackground(0.4392, 0.5020, 0.5647);

  // Bring up the render window and begin interaction.
  renWin->Render();
  iren->Start();
  
  // After the first interaction is quit, modifiy the ITK pipeline and
  // begin interaction again.  The user will see the ITK pipeline
  // re-execute due only to the update request through the VTK
  // pipeline.
  source->SetMinimum(0.5);
  iren->Start();
  
  // VTK does not use smart pointers, so we must clean up its pipeline
  // explicitly.
  iren->Delete();
  renWin->Delete();
  renderer->Delete();
  actor->Delete();
  shifter->Delete();
  vtkImporter->Delete();
  source->Delete();
  vtkExporter->Delete();
}

CVtkItkConnector::~CVtkItkConnector()
{
	//m_pImageData->Delete();
}


/**
 * This function will connect the given itk::VTKImageExport filter to
 * the given vtkImageImport filter.
 */
template <typename ITK_Exporter, typename VTK_Importer> 
void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)
{
  importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback
());
  importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback
());
  importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
  importer->SetSpacingCallback(exporter->GetSpacingCallback());
  importer->SetOriginCallback(exporter->GetOriginCallback());
  importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
  importer->SetNumberOfComponentsCallback(exporter-
>GetNumberOfComponentsCallback());
  importer->SetPropagateUpdateExtentCallback(exporter-
>GetPropagateUpdateExtentCallback());
  importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
  importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
  importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
  importer->SetCallbackUserData(exporter->GetCallbackUserData());
}

/**
 * This function will connect the given vtkImageExport filter to
 * the given itk::VTKImageImport filter.
 */
template <typename VTK_Exporter, typename ITK_Importer> 
void ConnectPipelines(VTK_Exporter* exporter, ITK_Importer importer)
{
  importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback
());
  importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback
());
  importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
  importer->SetSpacingCallback(exporter->GetSpacingCallback());
  importer->SetOriginCallback(exporter->GetOriginCallback());
  importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
  importer->SetNumberOfComponentsCallback(exporter-
>GetNumberOfComponentsCallback());
  importer->SetPropagateUpdateExtentCallback(exporter-
>GetPropagateUpdateExtentCallback());
  importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
  importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
  importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
  importer->SetCallbackUserData(exporter->GetCallbackUserData());
}
/////////////////////////////////////////////////////////////////////////
// VtkItkConnector.h: interface for the CVtkItkConnector class.
//
//////////////////////////////////////////////////////////////////////

#if !defined
(AFX_VTKITKCONNECTOR_H__25C4D179_9827_4E33_8D21_1DB4864645F0__INCLUDED_)
#define AFX_VTKITKCONNECTOR_H__25C4D179_9827_4E33_8D21_1DB4864645F0__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

//#include <itkCommand.h>
//#include <itkImage.h>
//#include <itkVTKImageImport.h>
//#include <itkVTKImageExport.h>
#include <vtkImageData.h>


class CVtkItkConnector  
{
public:
	
	CVtkItkConnector(/*vtkImageData* data*/);
	virtual ~CVtkItkConnector();
	vtkImageData* m_pImageData;
	template <typename ITK_Exporter, typename VTK_Importer>
      void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer);
	template <typename VTK_Exporter, typename ITK_Importer>
      void ConnectPipelines(VTK_Exporter* exporter, ITK_Importer importer);



};

#endif // !defined
(AFX_VTKITKCONNECTOR_H__25C4D179_9827_4E33_8D21_1DB4864645F0__INCLUDED_)


////////////////////////////////////////////////////////////////////////////
--------------------Configuration: OsirisLight - Win32 Debug--------------------
Linking...
VtkItkConnector.obj : error LNK2001: unresolved external symbol "public: void 
__thiscall CVtkItkConnector::ConnectPipelines(class itk::SmartPointer<class 
itk::VTKImageExport<class itk::Image<float,2> > >,class vtkImageImport *)" (?
ConnectPipelines@C
VtkItkConnector@@QAEXV?$SmartPointer@V?$VTKImageExport@V?
$Image@M$01@itk@@@itk@@@itk@@PAVvtkImageImport@@@Z)
VtkItkConnector.obj : error LNK2001: unresolved external symbol "public: void 
__thiscall CVtkItkConnector::ConnectPipelines(class vtkImageExport *,class 
itk::SmartPointer<class itk::VTKImageImport<class itk::Image<float,2> > >)" (?
ConnectPipelines@C
VtkItkConnector@@QAEXPAVvtkImageExport@@V?$SmartPointer@V?$VTKImageImport@V?
$Image@M$01@itk@@@itk@@@itk@@@Z)
Debug/OsirisLight.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

OsirisLight.exe - 3 error(s), 0 warning(s)

//////////////////////////////////////////////////////////////////////////////






-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/