[vtkusers] mismatch of datasize with declaration
nuno.jf
nunofernandes7 at gmail.com
Wed Jan 11 15:35:17 EST 2012
Dear users,
I am reading an image and trying to generate a surface.
I am using vtkImageGaussianSmooth and vtkImageMarchingCubes to smooth the
image and to generate the isocontours.
The problem is that, when using vtkImageMarchingCubes, for some min/max
range values I define in GenerateValues() I get the following message (when
trying to read the output file in paraview):
/Generic Warning: In ..\..\..\..\source\VTK\IO\vtkDataReader.cxx, line 1382
Error reading ascii data. Possible mismatch of datasize with declaration./
I noticed that thjs happens when I am computing normals
(ComputeNormalsOn()), because I wasn't able to reproduce this error without
ComputeNormalsOn().
Any help?
Here is my code:
/*=================================================
Name:
Input:
Output:
Arguments to run:
Nuno Fernandes
===================================================*/
============================================
int main( int argc, char *argv[] )
{
vtkStructuredPointsReader *imp1 = vtkStructuredPointsReader::New();
imp1 -> SetFileName( argv[1] );
imp1 -> Update();
vtkImageGaussianSmooth *smooth = vtkImageGaussianSmooth::New();
smooth->SetInput(imp1->GetOutput());
smooth->SetDimensionality(3);
smooth->SetStandardDeviations(1,1,1);
smooth->Update();
vtkSmartPointer<vtkImageMarchingCubes> mc =
vtkSmartPointer<vtkImageMarchingCubes>::New();
mc->SetInput(smooth->GetOutput());
mc->ComputeNormalsOn();
mc->ComputeGradientsOn();
mc->GenerateValues(1,atof(argv[2]),atof(argv[3]));
mc->Update();
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(.1, .2, .3);
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(renderWindow);
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(mc->GetOutputPort()); //mc->GetOutputPort()
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
renderer->AddActor(actor);
renderWindow->Render();
interactor->Start();
vtkPolyData * out =mc->GetOutput();
//Writer
vtkPolyDataWriter *writer =vtkPolyDataWriter::New();
writer ->SetInputConnection(out->GetProducerPort());
writer->SetFileTypeToASCII();
writer ->SetFileName("saida.vtk");
writer ->Update();
//XML Writer
vtkXMLPolyDataWriter * writer2 = vtkXMLPolyDataWriter::New();
writer2 ->SetInputConnection(out->GetProducerPort());
writer2->SetDataModeToAscii();
writer2->SetFileName("saidaXML.vtp");
writer2->Update();
}
--
View this message in context: http://vtk.1045678.n5.nabble.com/mismatch-of-datasize-with-declaration-tp5137973p5137973.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list