[vtkusers] Function to read a file

ClaudeG claude.gangolf at gmail.com
Mon Jul 6 10:30:20 EDT 2009


I'm still not clear on what the problem is?

Is a real file like this?
0 2
1.5 1.5 1.5 1.5 1.5 1.5
2.5 2.4 2.6 2.4  2.5 2.7
1 3
1.5 1.5 1.5 1.5 1.5 1.5
2.5 2.4 2.6 2.4  2.5 2.7
2.5 2.4 2.6 2.4  2.5 2.7

Are you trying to make each time step into a polydata? What do you want in
each polydata? a unit vector from the starting point in the direction (end -
start)? a vector between start and end? Do you want them to be lines or
arrows? Are you trying to display this from c++ or do you want to write it
to a file? From what you said you just want to store the values... so you
could do something like the below (just an outline, clearly) - but this
isn't a VTK question so it is better posed on a c++ mailing list:

struct Vec
{

	double x1,y1,z1,x2,y2,z2;
Vec(const double X1, const double Y1, const double Z1, const double
X2, const double Y2, const double Z2) : x1(X1), y1(Y1), z1(Z1),
x2(X2), y2(Y2), z2(Z2){}

};
//the outer std::vector is the time steps, the inner std::vector is the
std::vector<std::vector<Vec> > Vectors;

	while(getline(fin, line))
	{
//... figure out when a new time step starts ...

std::vector<Vec> CurrentTimeVectors;
		double x1,y1,z1,x2,y2,z2;
		std::stringstream linestream;
		linestream << line;
		linestream >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;

Vec v(x1,y1,z1,x2,y2,z1);
CurrentTimeVectors.push_back(v);

// ... when the current time step ends...
Vectors.push_back(CurrentTimeVectors);
	}



Thanks,

David


 Yes it's a file like you describe and i want to show this vector from the
starting to the ending point in c++, Vtk and therefore i must read this file
correctly and i want to put the vector on the center of the object where it
describe the velocity.

Thanks for you help


-- 
View this message in context: http://www.nabble.com/Function-to-read-a-file-tp24350476p24356512.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list