[vtkusers] Problem updating data on a StructuredPoints

thomas aime thomasaime0 at gmail.com
Mon Apr 29 05:51:28 EDT 2013


Hi, I'm new on this website, and I also have a little problem.
I try to take data from 3 structuredPoints and put it into 3 vtkDoubleArray
and put those into another vtkDoubleArray which contains data from the 3
StructuredPoints. All this to create a visualisation of the data of the
structuredPoints.
This is my code to that.
Thanks for every help ;)

void ReaderVolume(vector < const char *> TabVolumeFlux)

{



reader01->SetFileName(TabVolumeFlux[0]);

reader01->Update();

reader01->GetOutput()->ReleaseDataFlagOn();

reader02->SetFileName(TabVolumeFlux[1]);

reader02->Update();

reader02->GetOutput()->ReleaseDataFlagOn();

reader03->SetFileName(TabVolumeFlux[2]);

reader03->Update();

reader03->GetOutput()->ReleaseDataFlagOn();

sp1 = reader01->GetOutput();

sp2 = reader02->GetOutput();

sp3 = reader03->GetOutput();

sp1->Update();

sp2->Update();

sp3->Update();

string vol1, vol2, vol3;

vol1 = this->getStringTag((numflux-1), 1, 0x0018, 0x1030 );

vol2 = this->getStringTag((numflux-1)+getFluxNumber(), 1, 0x0018, 0x1030 );

vol3 = this->getStringTag((numflux-1)+getFluxNumber()*2, 1, 0x0018, 0x1030
);

if ( vol1.find("AP") != string::npos )

sp1->GetPointData()->GetScalars()->SetName("Y");

else if ( vol1.find("RL") != string::npos )

sp1->GetPointData()->GetScalars()->SetName("X");

else if ( vol1.find("FH") != string::npos )

sp1->GetPointData()->GetScalars()->SetName("Z");

if ( vol2.find("AP") != string::npos )

sp2->GetPointData()->GetScalars()->SetName("Y");

else if ( vol2.find("RL") != string::npos )

sp2->GetPointData()->GetScalars()->SetName("X");

else if ( vol2.find("FH") != string::npos )

sp2->GetPointData()->GetScalars()->SetName("Z");

if ( vol3.find("AP") != string::npos )

sp3->GetPointData()->GetScalars()->SetName("Y");

else if ( vol3.find("RL") != string::npos )

sp3->GetPointData()->GetScalars()->SetName("X");

else if ( vol3.find("FH") != string::npos )

sp3->GetPointData()->GetScalars()->SetName("Z");

 //Insert the 3StructuredPoints into one which name is sp1

sp1->GetPointData()->AddArray(sp2->GetPointData()->GetScalars());

sp1->GetPointData()->AddArray(sp3->GetPointData()->GetScalars());

sp1->Update();

polyVectors0=vtkDoubleArray::New();

polyVectors1=vtkDoubleArray::New();

polyVectors2=vtkDoubleArray::New();

polyVectors3=vtkDoubleArray::New();

polyScalars=vtkDoubleArray::New();

int tailleTotale=sp1->GetNumberOfPoints()*3;

polyVectors0->SetNumberOfComponents(3);

polyVectors1->SetNumberOfComponents(3);

polyVectors2->SetNumberOfComponents(3);

polyVectors3->SetNumberOfComponents(3);

polyScalars->SetNumberOfComponents(1);

polyVectors0->SetNumberOfTuples(tailleTotale);

polyVectors1->SetNumberOfTuples(tailleTotale);

polyVectors2->SetNumberOfTuples(tailleTotale);

polyVectors3->SetNumberOfTuples(tailleTotale);

polyScalars->SetNumberOfTuples(tailleTotale/3);

polyVectors0->Allocate(1);

polyVectors1->Allocate(1);

polyVectors2->Allocate(1);

polyVectors3->Allocate(1);

polyScalars->Allocate(1);

polyVectors1->DeepCopy(sp1->GetPointData()->GetArray("X"));

polyVectors2->DeepCopy(sp1->GetPointData()->GetArray("Y"));

polyVectors3->DeepCopy(sp1->GetPointData()->GetArray("Z"));

double racine;

for(int i=0;i<tailleTotale/3;i++)

{

polyVectors0->InsertNextTuple3(polyVectors1->GetTuple1(i),polyVectors2->GetTuple1(i),polyVectors3->GetTuple1(i));

racine=(polyVectors1->GetTuple1(i)*polyVectors1->GetTuple1(i))+(polyVectors2->GetTuple1(i)*polyVectors2->GetTuple1(i))+(polyVectors3->GetTuple1(i)*polyVectors3->GetTuple1(i));

racine=sqrt(racine);

polyScalars->InsertNextTuple1(racine);

}

int dimensions_v[3];

sp1->GetDimensions(dimensions_v);

double origines_v[3];

sp1->GetOrigin(origines_v);

double spacing_v[3];

sp1->GetSpacing(spacing_v);

 vtkStructuredPoints *v=vtkStructuredPoints::New();

v->SetNumberOfScalarComponents(1);

v->SetDimensions(dimensions_v[0],dimensions_v[1],dimensions_v[2]);

v->SetOrigin(origines_v[0],origines_v[1],origines_v[2]);

v->SetScalarTypeToFloat();

v->SetSpacing(spacing_v[0],spacing_v[1],spacing_v[2]);

v->GetPointData()->SetVectors(polyVectors01);

v->GetPointData()->SetVectors(polyVectors0);

v->GetPointData()->SetScalars(polyScalars);

v->Update();

vtkStructuredPointsWriter *writer= vtkStructuredPointsWriter::New();

writer->SetInput(v);

this->readerMerge->SetFileName("merge.vtk");

readerMerge->Update();

writer->SetFileName(this->readerMerge->GetFileName());

writer->Update();

writer->SetScalarsName("scalars");

writer->SetFileTypeToASCII();

writer->SetVectorsName("vectors");

writer->Write();

writer->Update();

v->Delete();

polyVectors1->Delete();

polyVectors2->Delete();

polyVectors3->Delete();

polyVectors0->Delete();

polyScalars->Delete();

writer->Delete();

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130429/637a3d6d/attachment.htm>


More information about the vtkusers mailing list