Hej ;)
Jestem very basic w c++.
Mam problem z wczytaniem pliku ze strumienia :
Nie wiem w czym robię, błąd :
Chcę przekazać w parametrze do funkcji.
Tutaj mój kod :
vtkPolyData * f(std::istream & infile)
{
vtkIdType number_of_points, number_of_triangles;
infile >> number_of_points >> number_of_triangles;
vtkSmartPointer<vtkPoints> points
= vtkSmartPointer<vtkPoints>::New();
points->SetNumberOfPoints(number_of_points);
for (vtkIdType i = 0; i < number_of_points; i++)
{
double x, y, z;
infile >> x >> y >> z;
points->SetPoint(i, x, y, z);
}
vtkSmartPointer<vtkCellArray> polys
= vtkSmartPointer<vtkCellArray>::New();
for (vtkIdType i = 0; i < number_of_triangles; i++)
{
vtkIdType a, b, c;
infile >> a >> b >> c;
polys->InsertNextCell(3);
polys->InsertCellPoint(a);
polys->InsertCellPoint(b);
polys->InsertCellPoint(c);
}
vtkPolyData * polydata = vtkPolyData::New();
polydata->SetPoints(points);
polydata->SetPolys(polys);
return polydata;
}
int main()
{
filebuf fb;
fb.open ("testFile.txt",ios::in);
istream infile(&fb);
// Tutaj ?? Nie wiem jak to przekazać, Chcę wywołać tą funcję - ciało funkcji powyżej
vtkPolyData *f(&infile);
// cout << char(is.get());
fb.close();
return EXIT_SUCCESS;
}
Bardzo proszę o pomoc ;)
Będę bardzo wdzięczna ;)
agatte;)