18 #include "vtkImageData.h"
19 #include "vtkImageReader2.h"
20 #include "vtkTIFFReader.h"
21 #include "vtkJPEGReader.h"
22 #include "vtkPNGReader.h"
28 int cmp_nocase(
const std::string& s,
const std::string& s2)
30 std::string::const_iterator p = s.begin();
31 std::string::const_iterator p2 = s2.begin();
32 while (p != s.end() && p2 != s2.end())
34 if (toupper(*p) != toupper(*p2))
35 return (toupper(*p) < toupper(*p2)) ? -1 : 1;
39 return (s2.size() == s.size()) ? 0 : (s.size() < s2.size()) ? -1 : 1;
48 this->
image(image_file);
60 o <<
"*******" << std::endl;
61 o <<
"a_image" << std::endl;
62 o <<
"*******" << std::endl;
63 o <<
"An object of this class is meant to store an image and its projection parameters" << std::endl;
64 o <<
"and to be use as a texture for a_element (a_trianglecloud in particular)" << std::endl;
65 o <<
"Commands:" << std::endl;
66 o <<
"--------" << std::endl;
67 o <<
"type: returns the string 'a_image'" << std::endl;
68 o <<
"image 'filename': load an image" << std::endl;
69 o <<
"pmatrix 'filename': load the P project matrix" << std::endl;
70 o <<
" see p_compute(1) to compute the matrix of a given image" << std::endl;
71 o <<
"name: set/get the name of the object" << std::endl;
77 std::ifstream
in(file.c_str());
92 vtkImageReader2 * reader;
94 reader = vtkTIFFReader::New();
96 reader = vtkJPEGReader::New();
98 reader = vtkPNGReader::New();
99 reader->SetFileName(
const_cast<char *
>(
image_file.c_str()));
100 texture_->SetInputConnection(reader->GetOutputPort());
102 bb_ = reader->GetOutput()->GetDimensions();
111 std::ifstream ff(matrix_file.c_str());
118 a_3dh p3d(x[0],x[1],x[2]);
119 a_2dh p2d =
p_->project(p3d);
122 if ((tcoord[0]<0.)||(tcoord[0]>
bb_[0])||(tcoord[1]<0.)||(tcoord[1]>
bb_[1]))
133 int n_pts = points->GetNumberOfPoints();
134 for (
int k = 0; k < n_pts; k++)
137 points->GetPoint(k,x);
140 tcoords->InsertNextTuple(tc);
148 for (
int i = 0; i <
v.size(); i++)
void delete_vector(std::vector< a_image * > &v)
int cmp_nocase(const std::string &s, const std::string &s2)
a_image(const std::string &image_file, const std::string &matrix_file)
void file_exist(const std::string &name) const
void image(const std::string &file_name)
void texture_coordinates(const double *x, float *tcoord) const
void pmatrix(const std::string &file_name)
static const std::string help()
void gettcoords(vtkPoints *, vtkFloatArray *tcoords) const
double v(const uint32_t step, const uint32_t n)
std::string image_file("")