ITK/Examples/SimpleOperations/BresenhamLine: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "==BresenhamLine.cxx== <source lang="cpp"> #include "itkBresenhamLine.h" #include "itkVector.h" #include "itkOffset.h" #include "itkPoint.h" #include <iostream> int main(int arg...")
 
(Deprecated content that is moved to sphinx)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==BresenhamLine.cxx==
{{warning|1=The media wiki content on this page is no longer maintained.  The examples presented on the https://itk.org/Wiki/*  pages likely require ITK version 4.13 or earlier releases.   In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.
<source lang="cpp">
}}
#include "itkBresenhamLine.h"
#include "itkVector.h"
#include "itkOffset.h"
#include "itkPoint.h"


#include <iostream>
[https://itk.org/ITKExamples[ITK Sphinx Examples]]
 
int main(int argc, char *argv[])
{
  // Get the points on a Bresenham line between (2,2) and (5,5)
  itk::Point<float,2> p0;
  p0[0] = 2;
  p0[1] = 2;
 
  itk::Point<float,2> p1;
  p1[0] = 5;
  p1[1] = 5;
 
  float dist = p0.EuclideanDistanceTo(p1);
 
  itk::BresenhamLine<2> line;
 
  itk::Vector<float, 2> v;
  v[0] = 1;
  v[1] = 1;
  std::vector< itk::Offset<2> > offsets = line.BuildLine(v, dist);
 
  itk::Index<2> p0index;
  p0index[0] = p0[0];
  p0index[1] = p0[1];
 
  for(unsigned int i = 0; i < offsets.size(); i++)
    {
    std::cout << p0index + offsets[i] << std::endl;
    }
 
  return EXIT_SUCCESS;
}
</source>
 
==CMakeLists.txt==
<source lang="cmake">
cmake_minimum_required(VERSION 2.6)
 
PROJECT(BresenhamLine)
 
FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})
 
ADD_EXECUTABLE(BresenhamLine BresenhamLine.cxx)
TARGET_LINK_LIBRARIES(BresenhamLine ITKIO)
 
</source>

Latest revision as of 15:04, 4 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.

[ITK Sphinx Examples]