[vtkusers] Using vtkImplicitDataSet as a clipping function

Roger Mason rmason at mun.ca
Wed May 11 10:58:56 EDT 2011


Hello,

I want to use a vtkImplicitDataSet to clip data.  The input data are a
series of layers (which I did not create) in OBJ file format.  Thus far I proceed as
follows:

(1) Read the layers into vtkPolyData objects.
(2) Use 5 planes to clip the front, back, left, right and bottom to
    create a block for display.
(3) Generate a clipping surface using vtkPerlinNoise applied to a plane
    with normal=00-1.
(4) Apply the clipping surface (as a vtkImplicitDataSet) to the results of
    steps 1 and 2, then display.

The problem is that the resulting display is empty of data.  I
instrumented the code to get some information on the polydata after step
2 and the clipping surface after step 3.  It appears the dimensions of
the data are very different:

polyData, line 288 -17 17 -21 21 -5.81891 43.8325
surface, line 304 1 -1 1 -1 1 -1

I'm guessing this difference is at least part of the problem.  I think
the relevant bit of code is this:

  vtkSmartPointer<vtkImplicitSum> sum 
    = vtkSmartPointer<vtkImplicitSum>::New();
  sum->SetNormalizeByWeight(1);
  sum->AddFunction(plane);
  sum->AddFunction(p1, 0.2); // p1,2 & 3 are vtkPerlinNois functions
  sum->AddFunction(p2, 0.1);
  sum->AddFunction(p3, 0.02);

  vtkSmartPointer<vtkSampleFunction> sample
    = vtkSmartPointer<vtkSampleFunction>::New();
  sample->SetImplicitFunction(sum);
  //  sample->SetSampleDimensions(65, 65, 20);
  //  sample->SetSampleDimensions(10, 10, 20);
  sample->SetModelBounds(-17, 17, -21, 21, -5, 5);
  //  sample->SetModelBounds(-10, 10, -10, 10, -0.5, 0.5);
  sample->ComputeNormalsOff();

  vtkSmartPointer<vtkContourFilter> surface
    = vtkSmartPointer<vtkContourFilter>::New();
  surface->SetInputConnection(sample->GetOutputPort());
  surface->SetValue(0, 0.0);

  vtkSmartPointer<vtkPolyDataNormals> smooth
    = vtkSmartPointer<vtkPolyDataNormals>::New();
  smooth->SetInputConnection(surface->GetOutputPort());
  smooth->SetFeatureAngle(90);

  return surface->GetOutput();
  //  return sample->GetOutput(); // won't compile

I'm not at all experienced using VTK and if someone can point out my
errors I'll be most grateful.

Thanks,
Roger



More information about the vtkusers mailing list