Clipping poly data

Paul Hsieh pahsieh at usgs.gov
Thu Sep 2 17:49:29 EDT 1999


John: I think the documentation is incorrect when it says that you need to
always apply the GenerateClipScalarsOn method if you want to clip with
an implicit function. I have done clipping with implicit function many
times without applying GenerateClipScalarsOn. The description of this 
method is:

"...the output scalar values will be interpolated from the implicit function values, 
and not the input scalar data."

This is not what you want, and explains why you lose your colors.
Eliminate 
    xClipper->GenerateClipScalarsOn();
and your code should work. Hopefully...

John Washbourne wrote:
> 
> Hello,
> 
> I have a problem with clipping planes for a C++ vtk pipeline. I am using
> a clip plane as an implicit function to clip a slice plane from a
> structured grid.  I had the slice plane working fine, but want to clip
> part of it away.
> 
> The problem: after clipping I lose the scalars that color the slice
> plane. I attach a code fragment below to illustrate.
> 
> Perhaps someone can provide a workaround, or a better way to do this.
> 
> Thanks in advance for any advice,
> 
> john washbourne
> 
> CODE FRAGMENT FOLLOWS:
> 
>   vtkPlane *cPlane = vtkPlane::New();
>     cPlane->SetOrigin(clipx,clipy,clipz);
>     cPlane->SetNormal(dx,dy,dz);
> 
> // X slice plane
> //
> .......................................................................
>   if ( xslice>0.0 ) {
>     vtkStructuredGridGeometryFilter *xSlice =
>           vtkStructuredGridGeometryFilter::New();
>       ix = nint((float)(nGrid)*xslice/100.0f);
>       xSlice->SetExtent (ix,ix, 0,nGrid-1, 0,nLayers);
>       xSlice->SetInput (sgrid);
> 
>     vtkClipPolyData *xClipper = vtkClipPolyData::New();
>       xClipper->SetInput(xSlice->GetOutput());
>       xClipper->SetClipFunction(cPlane);
>       xClipper->GenerateClipScalarsOn();
>       xClipper->SetValue(0.0);
>       xClipper->InsideOutOn();
>       xClipper->DebugOn();
> 
>     vtkPolyDataMapper *xSliceMapper = vtkPolyDataMapper::New();
>       xSliceMapper->SetInput(xClipper->GetOutput());
>       xSliceMapper->ScalarVisibilityOn();
>       xSliceMapper->SetScalarRange (vmin, vmax);
>       xSliceMapper->SetLookupTable (lut);
> 
>     vtkActor *xSlicePlane = vtkActor::New();
>       xSlicePlane->SetMapper(xSliceMapper);
> 
>     renderer->AddActor(xSlicePlane);
>   }


-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list