Okay, that example works now.
I put now the concept into the real Program:
Code:
//pcavis.h
#include <vtkCylinderSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkXRenderWindowInteractor.h>
#include <vtkProperty.h>
#include <vtkCamera.h>
#include <vtkConeSource.h>
#include <vtkSphereSource.h>
#include <vtkGlyph3D.h>
#include <vtkPoints.h>
#include <vtkFloatArray.h>
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
struct SimpVec
{
float coordx;
float coordy;
float coordz;
};
vector<SimpVec> vecs;
Code:
//main.C
#include "pcavis.h"
#define RESOLUTION 20
#define POINTRADIUS 0.05
void datareader();
//void pcavis2();
int main(int argc, char *argv[])
{
datareader();
}
Code:
#include "pcavis.h"
//int dimen;
//void pcavis2(vector<SimpVec> ChargeVec, int anz);
void datareader()
{
int i = 0;
int anz = 0;
SimpVec einVektor;
int real; // number of right vectors, length of vecs
int err; // number of errorous vectors
einVektor.coordx = 0.0; // this is a dummy assigment to force the compiler to link floating point support
FILE *pfile = fopen("pca.raw", "r");
if (!pfile) {
printf("pcaFile not found!\n");
i = 1;
}
else {
while (fscanf(pfile, "%f;%f;%f;\n", &einVektor.coordx, &einVektor.coordy, &einVektor.coordz) != EOF) {
printf("Line %d has the following Vectordata: %f %f %f\n", anz, einVektor.coordx, einVektor.coordy, einVektor.coordz);
real = anz - err;
vecs::resize(real);
vecs.at(real).coordx = einVektor.coordx;
vecs.at(real).coordy = einVektor.coordy;
vecs.at(real).coordz = einVektor.coordz;
anz++;
}
if (!feof(pfile)) {
printf("Error while reading the line!\n");
err++;
anz++;
}
else
//printf("That are %d Vectors!\n", anz);
cout << "That are " << anz << " lines with " << real << " gueltigen Vektoren" << endl;
fclose(pfile);
}
}
Compiling gives me the following Errors:
Datareader.C: In function `void datareader()':
Datareader.C:25: parse error before `::'
Datareader.C:26: no matching function for call to `vector<SimpVec,allocator<SimpVec> >::at (int &)'
Datareader.C:27: no matching function for call to `vector<SimpVec,allocator<SimpVec> >::at (int &)'
Datareader.C:28: no matching function for call to `vector<SimpVec,allocator<SimpVec> >::at (int &)'
That vector called vecs is defined in pcavis.h so it won't be deleted after the datareadingpart is done, so i can give it to the vtk-stuff which will be called in main.C
edit:
There is a logical 'bug' preventing from doing what i want, but it is NOT affecting the compilingerror
Thanks in advance!
Jan