ITK/Examples/SimpleOperations/CreateVector

From KitwarePublic

Jump to: navigation, search

Create a variable length vector. This is the ITK version of std::vector.

CreateVector.cxx

#include <itkVector.h>
 
int main(int, char*[])
{
  typedef itk::Vector<double, 3> VectorType;
  VectorType v;
  v[0] = 1.0;
  v[1] = 2.0;
  v[2] = 3.0;
  std::cout << "v: " << v << std::endl;
 
  return EXIT_SUCCESS;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
 
project(CreateVector)
 
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
 
add_executable(CreateVector CreateVector.cxx)
 
if( "${ITK_VERSION_MAJOR}" LESS 4 )
  target_link_libraries(CreateVector ITKReview ${ITK_LIBRARIES})
else( "${ITK_VERSION_MAJOR}" LESS 4 )
  target_link_libraries(CreateVector ${ITK_LIBRARIES})
endif( "${ITK_VERSION_MAJOR}" LESS 4 )
Personal tools