ITK/Examples/SimpleOperations/BresenhamLine: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
Daviddoria (talk | contribs) No edit summary |
(Only available in ITKv4) |
||
Line 1: | Line 1: | ||
==BresenhamLine.cxx== | ==BresenhamLine.cxx== | ||
<source lang="cpp"> | <source lang="cpp"> | ||
#if ( ITK_VERSION_MAJOR < 4 )//This only works with ITKv4 | |||
int main(int argc, char *argv[]) | |||
{ | |||
return 0; | |||
} | |||
#else | |||
#include "itkBresenhamLine.h" | #include "itkBresenhamLine.h" | ||
#include "itkVector.h" | #include "itkVector.h" | ||
Line 8: | Line 16: | ||
#include <iostream> | #include <iostream> | ||
void Vector(); | static void Vector(void); | ||
void Line(); | static void Line(void); | ||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||
Line 15: | Line 23: | ||
Vector(); | Vector(); | ||
Line(); | Line(); | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
void Vector() | void Vector(void) | ||
{ | { | ||
Line 36: | Line 44: | ||
} | } | ||
void Line() | void Line(void) | ||
{ | { | ||
Line 43: | Line 51: | ||
pixel0[0] = 0; | pixel0[0] = 0; | ||
pixel0[1] = 0; | pixel0[1] = 0; | ||
itk::Index<2> pixel1; | itk::Index<2> pixel1; | ||
pixel1[0] = 5; | pixel1[0] = 5; | ||
pixel1[1] = 5; | pixel1[1] = 5; | ||
std::vector< itk::Index<2> > pixels = line.BuildLine(pixel0, pixel1); | std::vector< itk::Index<2> > pixels = line.BuildLine(pixel0, pixel1); | ||
Line 56: | Line 64: | ||
} | } | ||
#endif | |||
</source> | </source> | ||
Revision as of 16:42, 1 March 2011
BresenhamLine.cxx
<source lang="cpp">
- if ( ITK_VERSION_MAJOR < 4 )//This only works with ITKv4
int main(int argc, char *argv[]) {
return 0;
}
- else
- include "itkBresenhamLine.h"
- include "itkVector.h"
- include "itkOffset.h"
- include "itkPoint.h"
- include <iostream>
static void Vector(void); static void Line(void);
int main(int argc, char *argv[]) {
Vector(); Line();
return EXIT_SUCCESS;
}
void Vector(void) {
itk::BresenhamLine<2> line;
itk::Vector<float, 2> v; v[0] = 1; v[1] = 1; std::vector< itk::Offset<2> > offsets = line.BuildLine(v, 4);
for(unsigned int i = 0; i < offsets.size(); i++) { std::cout << offsets[i] << std::endl; }
}
void Line(void) {
itk::BresenhamLine<2> line; itk::Index<2> pixel0; pixel0[0] = 0; pixel0[1] = 0;
itk::Index<2> pixel1; pixel1[0] = 5; pixel1[1] = 5;
std::vector< itk::Index<2> > pixels = line.BuildLine(pixel0, pixel1);
for(unsigned int i = 0; i < pixels.size(); i++) { std::cout << pixels[i] << std::endl; }
}
- endif
</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>