[vtkusers] vtkPNMReader
Charles Law
charles.law at kitware.com
Fri Feb 9 11:09:17 EST 2001
Ahmed,
Sounds like thrashing to me. Try putting a vtkImageDataStreamer after the
shrink, or a vtkPolyDataStreamer after the marching cubes filter.
Charles.
At 10:34 PM 2/7/01 +0200, Ahmed Mahmoud wrote:
>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 10 hours without result.
>I tried to render 10 files at a time and it works fine.
>What is the problem??
>
>I'm using vtk 2.3 with Visual c++ .
>
>this my code
>/////////////////////////////
> vtkPNMReader *reader=vtkPNMReader::New();
> reader->SetFilePrefix (STUDY);
> reader->SetDataSpacing (PIXEL_SIZE,PIXEL_SIZE ,SPACING);
> reader->SetDataOrigin(originx,originy,SPACING);
> reader->SetDataVOI (0 ,512 ,0 ,512 ,m_start,m_end);
> reader->SetTransform(hfsi);
> reader->GetOutput()-> ReleaseDataFlagOn();
>
> vtkImageShrink3D *shrinker=vtkImageShrink3D::New();
> shrinker->SetInput (reader->GetOutput());
> shrinker->SetShrinkFactors(SAMPLE_RATE[0],SAMPLE_RATE[1],SAMPLE_RATE[2]);
> shrinker->AveragingOn();
>
> vtkImageGaussianSmooth *gaussian=vtkImageGaussianSmooth::New();
> gaussian->SetInput (shrinker->GetOutput());
> gaussian->SetDimensionality(3);
> gaussian->SetStandardDeviation
>(GAUSSIAN_STANDARD_DEVIATION[0],GAUSSIAN_STANDARD_DEVIATION[1],GAUSSIAN_STAN
>DARD_DEVIATION[2]);
> gaussian->SetRadiusFactor(1);
>
>
> 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
>
>
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at:
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list