Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- double f(double,double,double,double,double);
- int main()
- {
- ofstream myfile;
- myfile.open("example.vtk",ios::out|ios::app|ios::binary);
- myfile <<"# vtk DataFile Version 2.0\n";
- myfile<<"Testdata \n";
- myfile<<"BINARY \n";
- myfile<<"DATASET STRUCTURED_POINTS \n";
- myfile<<"DIMENSIONS 5 5 5 5 5 \n";
- myfile<<"ORIGIN -2 -2 -2 -2 -2 \n";
- myfile<<"SPACING 1 1 1 1 1 \n";
- myfile<<"POINT_DATA 3125\n";
- myfile<<"SCALARS scalarfield double\n";
- myfile<<"LOOKUP_TABLE default\n";
- double p1,p2,p3,p4,p5;
- double start1=-2.0; double spacing1=1.0; int nre=5;
- double start2=-2.0; double spacing2=1.0; int nrd=5;
- double start3=-2.0; double spacing3=1.0; int nrc=5;
- double start4=-2.0; double spacing4=1.0; int nrb=5;
- double start5=-2.0; double spacing5=1.0; int nra=5;
- for(int a=0;a<nra;a++)
- {
- for(int b=0;b<nrb;b++)
- {
- for(int c=0;c<nrc;c++)
- {
- for(int d=0;d<nra;d++)
- {
- for(int e=0;e<nre;e++)
- {
- p1=start5+e*spacing1;
- p2=start5+d*spacing2;
- p3=start5+c*spacing3;
- p4=start5+b*spacing4;
- p5=start5+a*spacing5;
- myfile<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" "<<p5<<" "<<f(p1,p2,p3,p4,p5)<<endl;
- //myfile.write((char *)&f(p1,p2,p3,p4,p5), sizeof(double));
- }
- }
- }
- }
- }
- myfile.close();
- return 0;
- }
- double f(double p1,double p2,double p3,double p4,double p5)
- {
- return (p1*p1+p2*p2+p3*p3+p4*p4+p5*p5);
- }
Add Comment
Please, Sign In to add comment