[vtkusers] vtkContourFilter

c674 c674332 at web.de
Sat Nov 1 09:58:46 EDT 2008


Found out about the vtkImplicitModeller, replaced the vtkCellDataToPontData
with it and am satisfied with the result.
What I dislike though, is that the contoured polydata contains the isovalue
as scalar value and not the isovalue the cells had before. I could change
the isovalue of course, but the generated surface looks best with an
isovalue of 1. Therefore I want to change the scalar values to a specified
value, for example 16. Unfortunately GetNumberOfTuples() in the following
code gives me a segmentation fault. What do I do wrong or is there another
more efficient way to accomplish this?

  vtkContourFilter* contour = vtkContourFilter::New();
  contour->SetInputConnection(im->GetOutputPort());
  contour->SetValue(0,1);
  
  vtkPolyData* polyData = contour->GetOutput();
  vtkCellData* cellData = polyData->GetCellData();
  vtkDataArray* colors = cellData->GetScalars();
  for(int i=0; i<colors->GetNumberOfTuples(); i++)
     colors->SetComponent(i,0,16);

Thanks in advance


c674 wrote:
> 
> What I am trying to do is put a surface over data in an unstructured grid,
> containing cubes with cell data. My code looks like this:
> 
> 	vtkUnstructuredGridReader* reader = vtkUnstructuredGridReader::New();
> 	reader->SetFileName("test_input.vtk");
> 	reader->Update();
> 	vtkCellDataToPointData* conv = vtkCellDataToPointData::New();
> 	conv->SetInput(reader->GetOutput());
> 	vtkContourFilter* contour = vtkContourFilter::New();
> 	contour->SetInput(conv->GetOutput());
> 	contour->SetValue(0,1);
>   	vtkPolyDataWriter* writer = vtkPolyDataWriter::New();
> 	writer->SetFileName("test_output.vtk");
> 	ostream *file= writer->OpenVTKFile();
>         writer->WriteHeader(file);
>         writer->SetInputConnection(contour->GetOutputPort());
> 	writer->Write();
>         writer->CloseVTKFile(file);
> 
> Unfortunately my output file does not contain any data. The cell data is
> in the range from 0 to 40. Does this give a hint on how to chose my
> isovalue? I've played with that value a lot, without success.
> When replacing the vtkCellDataToPointData with a
> vtkSurfaceReconstructionFilter I get output for isovalues between 1 and 3,
> I'm not satisfied with the look of the output though and I want it to work
> without that filter.
> What is the role of the isovalue anyways? I thought it was no more than
> some kind of threshold, to decide which points are taken into account -
> but then isovalues between 0 and 40 should give output, shouldn't they?
> 
-- 
View this message in context: http://www.nabble.com/vtkContourFilter-tp20268264p20280652.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list