<div>Hello All IGSTK Users and Developpers,</div><div><br></div><div>I' m fresh igstk user. I m doing first steps in igstk .</div><div>I work with  example LandmarkRegistration1(in Sandbox). </div><div>I use Visual Studio 2008.</div>
<div>I need to create dll and link  exe file.</div><div>I created dll . It works well. But I have a big problem with linking it with exe file.</div><div>I created  script in CMake.</div><div>I attach some of code :</div><div>
<br></div><div>I would to appreciate for any help please.</div><div><br></div><div>CMake script :</div><div>---------------------------------------------------------------------------------</div><div><div>cmake_minimum_required(VERSION 2.8)</div>
<div><br></div><div>PROJECT(LandmarkDLL)</div><div><br></div><div><br></div><div>FIND_PACKAGE(IGSTK)</div><div>IF(IGSTK_FOUND)</div><div>  INCLUDE(${IGSTK_USE_FILE})</div><div>ELSE(IGSTK_FOUND)</div><div>  MESSAGE(FATAL_ERROR</div>
<div>          "Cannot build without IGSTK.  Please set IGSTK_DIR.")</div><div>ENDIF(IGSTK_FOUND)</div><div><br></div><div>FIND_PACKAGE(OpenIGTLink)</div><div>IF(OpenIGTLink_FOUND)</div><div>  INCLUDE(${OpenIGTLink_USE_FILE})</div>
<div>ELSE(OpenIGTLink_FOUND)</div><div>  MESSAGE(FATAL_ERROR</div><div>          "Cannot build without OpenIGTLink.  Please set OpenIGTLink_DIR.")</div><div>ENDIF(OpenIGTLink_FOUND)</div><div><br></div><div><br>
</div><div><br></div><div>FIND_PACKAGE(IGSTKSandbox)</div><div>IF(IGSTKSandbox_FOUND)</div><div>  INCLUDE(${IGSTKSandbox_USE_FILE})</div><div>ELSE(IGSTKSandbox_FOUND)</div><div>  MESSAGE(FATAL_ERROR</div><div>          "Cannot build without IGSTK.  Please set IGSTK_DIR.")</div>
<div>ENDIF(IGSTKSandbox_FOUND)</div><div><br></div><div>INCLUDE_DIRECTORIES (</div><div>  ${IGSTKSandbox_SOURCE_DIR}</div><div>  ${IGSTKSandbox_BINARY_DIR}</div><div>  ${IGSTKSandbox_SOURCE_DIR}/Source</div><div>  ${IGSTKSandbox_BINARY_DIR}/Source</div>
<div>  )</div><div><br></div><div><br></div><div>  IF (IGSTKSandbox_USE_CompressedDV)</div><div>    SUBDIRS( VideoFrameGrabberAndViewerCompressedDV )</div><div>  ENDIF (IGSTKSandbox_USE_CompressedDV)</div><div><br></div><div>
  IF (IGSTKSandbox_USE_unicap)</div><div>    INCLUDE_DIRECTORIES(</div><div>    /usr/local/include/unicap</div><div>    )</div><div>    #SUBDIRS( VideoTemporalCalibrationWizard )</div><div>  ENDIF (IGSTKSandbox_USE_unicap)</div>
<div><br></div><div><br></div><div>  </div><div>   if(COMMAND cmake_policy)</div><div>      cmake_policy(SET CMP0003 NEW)</div><div>    endif(COMMAND cmake_policy)</div><div> </div><div><br></div><div><b>ADD_Executable(LandmarkDLL LandmarkDLL.h LandmarkDLL.cxx)</b></div>
<div><b>TARGET_LINK_LIBRARIES(LandmarkDLL IGSTKSandbox)</b></div><div><b><br></b></div><div><b><br></b></div><div><b>ADD_Executable(MainLandmarkDLL  MainLandmarkDLL.cxx)</b></div><div><b>TARGET_LINK_LIBRARIES(MainLandmarkDLL IGSTKSandbox)</b></div>
</div><div><br></div><div><br></div><div>----------------------------------------------------------------------------------</div><div><b>LandmarkDLL.h</b></div><div><br></div><div><div><b>#include <iostream></b></div>
<div><b>#include "igstkLandmark3DRegistration.h"</b></div><div><b>#include "igstkLogger.h"</b></div><div><b>#include "itkStdStreamLogOutput.h"</b></div><div><b>#include "itkObject.h"</b></div>
<div><b>#include "itkCommand.h"</b></div><div><b>#include "itkMacro.h"</b></div><div><b><br></b></div><div><b>#include "igstkEvents.h"</b></div><div><b>#include "igstkTransform.h"</b></div>
<div><b>#include "igstkCoordinateSystemTransformToResult.h" </b></div><div><b><br></b></div><div><b><br></b></div><div><b><br></b></div><div><b>namespace LandmarkD</b></div><div><b>{</b></div><div><b><br></b></div>
<div><b>class LandmarkDLL</b></div><div><b>{</b></div><div><b>public:</b></div><div><b><br></b></div><div><b><span class="Apple-tab-span" style="white-space:pre">  </span> static __declspec(dllexport) void Rejestracja();</b></div>
<div><b><br></b></div><div><b><br></b></div><div><b>};</b></div><div><b>}</b></div></div><div><b><br></b></div><div><b>-------------------------------------------------------------------------------------</b></div><div><b><br>
</b></div><div>LandmarkDLL.cxx</div><div><br></div><div><div>#include "LandmarkDLL.h"</div><div>#include <iostream></div><div><br></div><div>// BeginLatex</div><div>// </div><div>// To use the registration component, the header file for </div>
<div>// \doxygen{Landmark3DRegistration} is added:</div><div>//</div><div>// EndLatex</div><div><br></div><div>// BeginCodeSnippet</div><div>#include "igstkLandmark3DRegistration.h"</div><div>// EndCodeSnippet</div>
<div><br></div><div><br></div><div>#include "igstkLogger.h"</div><div>#include "itkStdStreamLogOutput.h"</div><div>#include "itkObject.h"</div><div>#include "itkCommand.h"</div><div>
#include "itkMacro.h"</div><div><br></div><div>// BeginLatex</div><div>// </div><div>// Transform parameters are returned to the application using loaded events. </div><div>// To handle these events, the following \doxygen{Events} </div>
<div>// and \doxygen{Transform} header files are needed:</div><div>//</div><div>// EndLatex</div><div><br></div><div>// BeginCodeSnippet</div><div>#include "igstkEvents.h"</div><div>#include "igstkTransform.h"</div>
<div>#include "igstkCoordinateSystemTransformToResult.h" </div><div>//#include "LandmarkDLL.h"</div><div><br></div><div>using namespace std;</div><div>// EndCodeSnippet</div><div><br></div><div><br></div>
<div>// BeginLatex</div><div>// </div><div>// To fully  utilize the registration component, callbacks need to be set up </div><div>// to observe events that could be thrown by the registration component.  </div><div>// For this purpose, the ITK command class is used to derive a callback class.</div>
<div>// The ITK command class implements a subject/observer (command design) pattern.</div><div>// A subject notifies an observer by running the \code{Execute } method of </div><div>// the derived callback class. For example, a callback class meant </div>
<div>// to observe an error in the transform computation is defined as follows:</div><div>// </div><div>// EndLatex</div><div><br></div><div>// BeginCodeSnippet</div><div>namespace LandmarkD</div><div>{</div><div>class Landmark3DRegistrationErrorCallback : public itk::Command</div>
<div>{</div><div>public:</div><div>  typedef Landmark3DRegistrationErrorCallback Self;</div><div>  typedef itk::SmartPointer<Self>             Pointer;</div><div>  typedef itk::Command                        Superclass;</div>
<div>  itkNewMacro(Self);</div><div>  void Execute(const itk::Object * itkNotUsed(caller), const itk::EventObject & itkNotUsed(event))</div><div>    {</div><div><br></div><div>    }</div><div>  void Execute(itk::Object * itkNotUsed(caller), const itk::EventObject & itkNotUsed(event))</div>
<div>    {</div><div>    std::cerr<<"Error in transform computation"<<std::endl;</div><div>    }</div><div>protected:</div><div>  Landmark3DRegistrationErrorCallback() {};</div><div><br></div><div>private:</div>
<div>};</div><div>//EndCodeSnippet</div><div><br></div><div><br></div><div>class Landmark3DRegistrationInvalidRequestCallback : public itk::Command</div><div>{</div><div>public:</div><div>  typedef Landmark3DRegistrationInvalidRequestCallback Self;</div>
<div>  typedef itk::SmartPointer<Self>                      Pointer;</div><div>  typedef itk::Command                                 Superclass;</div><div>  itkNewMacro(Self);</div><div>  void Execute(const itk::Object * itkNotUsed(caller), const itk::EventObject & itkNotUsed(event) )</div>
<div>    {</div><div><br></div><div>    }</div><div>  void Execute(itk::Object * itkNotUsed(caller), const itk::EventObject & itkNotUsed(event) )</div><div>    {</div><div>    std::cerr<<"Invalid input request!!"<<std::endl;</div>
<div>    }</div><div>protected:</div><div>  Landmark3DRegistrationInvalidRequestCallback() {};</div><div><br></div><div>private:</div><div>};</div><div><br></div><div>// BeginLatex</div><div>// </div><div>// Similarly, a callback class needs to be defined to observe the</div>
<div>// \doxygen{CoordinateSystemTransformToEvent} event. This event is loaded with</div><div>// transform parameters that are computed by the registration component.  The</div><div>// commands are as follows:</div><div>// EndLatex</div>
<div><br></div><div>// BeginCodeSnippet</div><div>class Landmark3DRegistrationGetTransformCallback: public itk::Command</div><div>{</div><div>public:</div><div>  typedef Landmark3DRegistrationGetTransformCallback    Self;</div>
<div>  typedef itk::SmartPointer<Self>                       Pointer;</div><div>  typedef itk::Command                                  Superclass;</div><div>  itkNewMacro(Self);</div><div><br></div><div>  typedef igstk::CoordinateSystemTransformToEvent TransformEventType;</div>
<div>  </div><div>  void Execute( const itk::Object * itkNotUsed(caller), const itk::EventObject & itkNotUsed(event) )</div><div>    {</div><div>    }</div><div> </div><div>  void Execute( itk::Object * itkNotUsed(caller), const itk::EventObject & event )</div>
<div>    {</div><div>    std::cout<< " TransformEvent is thrown" << std::endl;</div><div>    const TransformEventType * transformEvent =</div><div>      dynamic_cast < const TransformEventType* > ( &event );</div>
<div><br></div><div>    const igstk::CoordinateSystemTransformToResult transformCarrier =</div><div>      transformEvent->Get();</div><div><br></div><div>    m_Transform = transformCarrier.GetTransform();</div><div><br>
</div><div>    m_EventReceived = true;</div><div>    } </div><div>  bool GetEventReceived()</div><div>    {</div><div>    return m_EventReceived;</div><div>    }</div><div>  igstk::Transform GetTransform()</div><div>    {</div>
<div>    return m_Transform;</div><div>    }  </div><div>protected:</div><div><br></div><div>  Landmark3DRegistrationGetTransformCallback()   </div><div>    {</div><div>    m_EventReceived = true;</div><div>    }</div><div>
<br></div><div>private:</div><div>  bool m_EventReceived;</div><div>  igstk::Transform m_Transform;</div><div>};</div><div>// EndCodeSnippet</div><div><br></div><div><br></div><div>// BeginLatex</div><div>// </div><div>// For more information on IGSTK events, see Chapter~\ref{Chapter:Events}.</div>
<div>// After the helper classes are defined, the main function implementation </div><div>// is started, as follows:</div><div>//</div><div>// EndLatex</div><div><br></div><div>// BeginCodeSnippet</div><div><br></div><div>
<br></div><div> void LandmarkDLL::Rejestracja()</div><div>{</div><div><br></div><div><br></div><div><br></div><div>igstk::RealTimeClock::Initialize();</div><div><br></div><div><br></div><div>// BeginLatex</div><div>//</div>
<div>// Next, all the necessary data types are defined:</div><div>// </div><div>// EndLatex</div><div><br></div><div>// BeginCodeSnippet</div><div>  typedef igstk::Object::LoggerType             LoggerType;</div><div>  typedef itk::StdStreamLogOutput               LogOutputType;</div>
<div>    </div><div>  typedef igstk::Landmark3DRegistration</div><div>                            Landmark3DRegistrationType;</div><div>  typedef igstk::Landmark3DRegistration::LandmarkPointContainerType</div><div>                            LandmarkPointContainerType;</div>
<div>  typedef igstk::Landmark3DRegistration::LandmarkImagePointType </div><div>                            LandmarkImagePointType;</div><div>  typedef igstk::Landmark3DRegistration::LandmarkTrackerPointType</div><div>                            LandmarkTrackerPointType;</div>
<div>  typedef Landmark3DRegistrationType::TransformType::OutputVectorType </div><div>                            OutputVectorType;</div><div>  typedef igstk::Transform  TransformType;</div><div>// EndCodeSnippet</div><div>
<br></div><div><br></div><div>// BeginLatex</div><div>// </div><div>// Then, the registration component is instantiated as follows:</div><div>// </div><div>// EndLatex</div><div><br></div><div>// BeginCodeSnippet</div><div>
  Landmark3DRegistrationType::Pointer landmarkRegister = </div><div>                                        Landmark3DRegistrationType::New();</div><div>// EndCodeSnippet</div><div> </div><div><br></div><div>// BeginLatex</div>
<div>// </div><div>// Next, the landmark containers that hold the landmark image and tracker </div><div>// coordinates are instantiated:</div><div>//</div><div>// EndLatex</div><div><br></div><div>// BeginCodeSnippet</div>
<div>  LandmarkPointContainerType  imagePointContainer;</div><div>  LandmarkPointContainerType  trackerPointContainer;</div><div>// EndCodeSnippet</div><div><br></div><div><br></div><div>  LandmarkImagePointType      imagePoint;</div>
<div>  LandmarkTrackerPointType    trackerPoint;</div><div><br></div><div>// BeginLatex</div><div>// </div><div>// Then, error event callback objects are instantiated and added to the observer</div><div>// list of the registration component, as follows:</div>
<div>//</div><div>// EndLatex</div><div><br></div><div>// BeginCodeSnippet</div><div>  Landmark3DRegistrationInvalidRequestCallback::Pointer </div><div>                  lrcb = Landmark3DRegistrationInvalidRequestCallback::New();</div>
<div>    </div><div>  typedef igstk::InvalidRequestErrorEvent  InvalidRequestEvent;</div><div><br></div><div>  landmarkRegister->AddObserver( InvalidRequestEvent(), lrcb );</div><div><br></div><div>  Landmark3DRegistrationErrorCallback::Pointer ecb = </div>
<div>                  Landmark3DRegistrationErrorCallback::New();</div><div>  typedef igstk::Landmark3DRegistration::TransformComputationFailureEvent </div><div>                                                     ComputationFailureEvent;</div>
<div>  landmarkRegister->AddObserver( ComputationFailureEvent(), ecb );</div><div><br></div><div>// EndCodeSnippet</div><div><br></div><div>// BeginLatex</div><div>// </div><div>// A logger can then be connected to the registration component for </div>
<div>// debugging purpose, as follows:</div><div>//</div><div>// EndLatex</div><div><br></div><div><br></div><div>// BeginCodeSnippet </div><div>  LoggerType::Pointer   logger = LoggerType::New();</div><div>  LogOutputType::Pointer logOutput = LogOutputType::New();</div>
<div>  logOutput->SetStream( std::cout );</div><div>  logger->AddLogOutput( logOutput );</div><div>  logger->SetPriorityLevel( LoggerType::DEBUG );</div><div>  landmarkRegister->SetLogger( logger );</div><div>
// EndCodeSnippet</div><div>   </div><div><br></div><div><br></div><div><br></div><div>// BeginCodeSnippet</div><div>  // Add 1st landmark</div><div>  imagePoint[0] =  25.0;</div><div>  imagePoint[1] =  1.0;</div><div>  imagePoint[2] =  15.0;</div>
<div>  imagePointContainer.push_back(imagePoint);</div><div>  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);</div><div><br></div><div>  trackerPoint[0] =  29.8;</div><div>  trackerPoint[1] =  -5.3;</div><div>
  trackerPoint[2] =  25.0;</div><div>  trackerPointContainer.push_back(trackerPoint);</div><div>  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);</div><div><br></div><div>  // Add 2nd landmark</div><div>
  imagePoint[0] =  15.0;</div><div>  imagePoint[1] =  21.0;</div><div>  imagePoint[2] =  17.0;</div><div>  imagePointContainer.push_back(imagePoint);</div><div>  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);</div>
<div>    </div><div>  trackerPoint[0] =  35.0;</div><div>  trackerPoint[1] =  16.5;</div><div>  trackerPoint[2] =  27.0;</div><div>  trackerPointContainer.push_back(trackerPoint);</div><div>  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);</div>
<div><br></div><div>  // Add 3d landmark</div><div>  imagePoint[0] =  14.0;</div><div>  imagePoint[1] =  25.0;</div><div>  imagePoint[2] =  11.0;</div><div>  imagePointContainer.push_back(imagePoint);</div><div>  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);</div>
<div><br></div><div>  trackerPoint[0] =  36.8;</div><div>  trackerPoint[1] =  20.0;</div><div>  trackerPoint[2] =  21.0;</div><div>  trackerPointContainer.push_back(trackerPoint);</div><div>  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);</div>
<div><br></div><div>  // EndCodeSnippet</div><div><br></div><div>  // BeginLatex</div><div>  // </div><div>  // More landmarks can be added for the transform computation.  </div><div>  // </div><div>  // EndLatex</div><div>
<br></div><div>  // Add 4th landmark</div><div>  imagePoint[0] =  10.0;</div><div>  imagePoint[1] =  11.0;</div><div>  imagePoint[2] =  8.0;</div><div>  imagePointContainer.push_back(imagePoint);</div><div>  landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);</div>
<div><br></div><div>  trackerPoint[0] =  24.7;</div><div>  trackerPoint[1] =  12.0;</div><div>  trackerPoint[2] =  18.0;</div><div>  trackerPointContainer.push_back(trackerPoint);</div><div>  landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);</div>
<div><br></div><div>  // BeginLatex</div><div>  // </div><div>  // After all landmark coordinates are added, the transform computation is </div><div>  // requested as follows:</div><div>  // </div><div>  // EndLatex</div>
<div><br></div><div>  // Calculate transform</div><div><br></div><div>  // BeginCodeSnippet</div><div>  landmarkRegister->RequestComputeTransform();</div><div>  // EndCodeSnippet</div><div>     </div><div>  typedef itk::VersorRigid3DTransform<double>        VersorRigid3DTransformType;</div>
<div>  typedef VersorRigid3DTransformType::ParametersType ParametersType;</div><div><br></div><div>  TransformType      transform;</div><div>  ParametersType     parameters(6);</div><div><br></div><div>  // BeginLatex</div>
<div>  // </div><div>  // To access the transform parameters, a GetTransform callback is instantiated</div><div>  // to observe the transform event, as follows: </div><div>  // </div><div>  // EndLatex</div><div><br></div>
<div>  // BeginCodeSnippet</div><div>  Landmark3DRegistrationGetTransformCallback::Pointer lrtcb =</div><div>    Landmark3DRegistrationGetTransformCallback::New();</div><div><br></div><div>  landmarkRegister->AddObserver( </div>
<div>    igstk::CoordinateSystemTransformToEvent(), lrtcb );</div><div>  //EndCodeSnippet</div><div><br></div><div><br></div><div>  // BeginLatex</div><div>  //</div><div>  // To request that the registration component throw an event loaded with </div>
<div>  // transform parameters, a \code{RequestGetTransform} function is invoked as </div><div>  // follows:</div><div>  // </div><div>  // EndLatex</div><div><br></div><div>  // BeginCodeSnippet</div><div>  landmarkRegister->RequestGetTransformFromTrackerToImage();</div>
<div>  std::cout << "Transform " << transform << std::cout;</div><div>  // EndCodeSnippet</div><div><br></div><div>  </div><div>}</div><div><br></div><div>}</div><div style="font-weight: bold; ">
-------------------------------------------------------------------------------------------------------</div></div><div>MainLandmark.cxx </div><div><br></div><div><div>#include <iostream></div><div>#include "LandmarkDLL.h"</div>
<div>#include "igstkLandmark3DRegistration.h"</div><div><br></div><div> </div><div><br></div><div>#include "igstkLogger.h"</div><div>#include "itkStdStreamLogOutput.h"</div><div>#include "itkObject.h"</div>
<div>#include "itkCommand.h"</div><div>#include "itkMacro.h"</div><div>#include "igstkEvents.h"</div><div>#include "igstkTransform.h"</div><div>#include "igstkCoordinateSystemTransformToResult.h" </div>
<div><br></div><div>using namespace std;</div></div><div><br></div><div><div>int main()</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>LandmarkD::LandmarkDLL::Rejestracja();</div>
<div>    cout<<" Example LandmarkRegistration1"<<endl;</div><div>    system("Pause");</div><div><span class="Apple-tab-span" style="white-space:pre">   </span></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>return 0;</div>
<div>}</div></div><div><br></div><div><br></div><div><br></div><div>-----------------------------------------------</div><div><br></div><div>Best,</div><div><br></div><div>Agata </div><div><br></div>