[vtkusers] 3D of PNM files
Ahmed Mahmoud
ahmedmm at gega.net
Sat Jun 16 12:26:39 EDT 2001
Hello all,
I have 93 files pnm format and I want to make 3D for them.
When I render the whole files , it takes more than 12 hours without result.
I tried to render 10 files at a time and it works fine.
Please , What is the problem??
I'm using vtk 2.3 with Visual c++ .
this my code
/////////////////////////////
vtkPNMReader *reader=vtkPNMReader::New();
reader->SetFilePrefix ();
reader->SetDataSpacing ();
reader->SetDataOrigin();
reader->GetOutput()-> GlobalReleaseDataFlagOn();
vtkImageShrink3D *shrinker=vtkImageShrink3D::New();
shrinker->SetInput (reader->GetOutput());
vtkImageGaussianSmooth *gaussian=vtkImageGaussianSmooth::New();
gaussian->SetInput (shrinker->GetOutput());
gaussian->SetDimensionality(3);
vtkImageToStructuredPoints
*toStructuredPoints=vtkImageToStructuredPoints::New();
toStructuredPoints ->SetInput(gaussian ->GetOutput());
toStructuredPoints ->Update ();
toStructuredPoints ->GetOutput()->ReleaseDataFlagOn();
vtkMarchingCubes *mcubes=vtkMarchingCubes::New();
mcubes->SetInput(toStructuredPoints->GetOutput());
mcubes->ComputeScalarsOff();
mcubes->ComputeGradientsOff();
mcubes->ComputeNormalsOff();
mcubes->SetValue(0,70);
mcubes->GetOutput()->ReleaseDataFlagOn();
vtkDecimate *decimator=vtkDecimate::New();
decimator->SetInput(mcubes->GetOutput());
decimator->SetInitialFeatureAngle(DECIMATE_ANGLE);
decimator->SetMaximumIterations(DECIMATE_ITERATIONS);
decimator->SetMaximumSubIterations(0);
decimator->PreserveEdgesOn();
decimator->SetMaximumError(1);
decimator->SetTargetReduction (DECIMATE_REDUCTION);
decimator->SetInitialError (DECIMATE_ERROR);
decimator->SetErrorIncrement(DECIMATE_ERROR_INCREMENT);
decimator->GetOutput()->ReleaseDataFlagOn();
vtkSmoothPolyDataFilter *smoother=vtkSmoothPolyDataFilter::New();
smoother->SetInput(decimator->GetOutput());
smoother->SetNumberOfIterations(SMOOTH_ITERATIONS);
smoother->SetRelaxationFactor (SMOOTH_FACTOR);
smoother->SetFeatureAngle (SMOOTH_ANGLE);
smoother->FeatureEdgeSmoothingOff();
smoother->BoundarySmoothingOff();
smoother->SetConvergence(0);
smoother->GetOutput()->ReleaseDataFlagOn();
vtkPolyDataNormals *normals=vtkPolyDataNormals::New();
normals->SetInput(smoother->GetOutput());
normals->SetFeatureAngle (FEATURE_ANGLE);
normals->GetOutput()->ReleaseDataFlagOn();
vtkStripper *stripper=vtkStripper::New();
stripper->SetInput(normals->GetOutput());
stripper->GetOutput()->ReleaseDataFlagOn();
vtkPolyDataWriter *writer=vtkPolyDataWriter::New();
writer->SetInput(stripper->GetOutput());
writer->SetFileName(File);
writer->SetFileType(2);
writer->Update();
Thank you.
Ahmed
Ahmedmm at gega.net
More information about the vtkusers
mailing list