Problem with vtkClipPolyData
Bill Lorensen
wlorens1 at nycap.rr.com
Sat Mar 25 11:29:10 EST 2000
Paul,
As usual, thanks for the explicit bug report with an example. I found the problem and the fix will appear in tonight's build. I'm also adding your example as a regression test.
Bill
At 08:32 PM 3/24/00 -0800, pahsieh at usgs.gov wrote:
>I am running into a problem with vtkClipPolyData when the
>dataset contains cell scalars. The filter does not seem to
>work correctly with GenerateClippedOutputOn, but
>works fine with GenerateClippedOutputOff.
>
>This problem is illustrated by the attached sample code.
>A structured points data set is created with cell scalars,
>and is then passed through a geometry filter to obtain
>a poly dataset for clipping.
>
>Clipping is done twice on the poly dataset, the first time
>with GenerateClippedOutputOn, and the second time with
>GenerateClippedOutputOff. The resulting actors are different.
>
>This problem occurs in both vtk 2.3 and vtk 3.1 ("official"
>release). The problem also occurs when the clipped dataset is
>a structured grid that has been passed through a geometry filter,
>or a poly data created from scratch.
>
>Thanks for any help and best regards,
>-- Paul
>
>//======= sample code =======
>
>#include "vtkRenderer.h"
>#include "vtkRenderWindow.h"
>#include "vtkRenderWindowInteractor.h"
>#include "vtkStructuredPoints.h"
>#include "vtkGeometryFilter.h"
>#include "vtkPlane.h"
>#include "vtkClipPolyData.h"
>#include "vtkPolyDataMapper.h"
>#include "vtkActor.h"
>
>void main()
>{
> // Create the rendering stuff
> vtkRenderer *ren = vtkRenderer::New();
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer(ren);
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
>
> // Create a structured points data set
> vtkStructuredPoints *sp = vtkStructuredPoints::New();
> sp->SetDimensions(11, 11, 1);
> sp->SetSpacing(1, 1, 1);
> sp->SetOrigin(0, 0, 0);
>
> // Create some cell scalar data.
> vtkScalars *scalars = vtkScalars::New();
> for (int i=0; i<100; i++)
> {
> scalars->InsertNextScalar(0.01 * i);
> }
> sp->GetCellData()->SetScalars(scalars);
> scalars->Delete();
>
> // Use the geometry filter to make a poly data set.
> vtkGeometryFilter *geom = vtkGeometryFilter::New();
> geom->SetInput(sp);
>
> // Define the clipping plane x = 2.5
> vtkPlane *plane = vtkPlane::New();
> plane->SetNormal(1, 0, 0);
> plane->SetOrigin(2.5, 0, 0);
>
> // Clip the data with GenerateClippedOutputOn
> vtkClipPolyData *clip1 = vtkClipPolyData::New();
> clip1->SetInput(geom->GetOutput());
> clip1->SetClipFunction(plane);
> clip1->GenerateClippedOutputOn();
>
> vtkPolyDataMapper *mapper1 = vtkPolyDataMapper::New();
> mapper1->SetInput(clip1->GetOutput());
> mapper1->SetScalarModeToUseCellData();
>
> vtkActor *actor1 = vtkActor::New();
> actor1->SetMapper(mapper1);
>
> // Clip the same date with GenerateClippedOutputOff
> vtkClipPolyData *clip2 = vtkClipPolyData::New();
> clip2->SetInput(geom->GetOutput());
> clip2->SetClipFunction(plane);
> clip2->GenerateClippedOutputOff();
>
> vtkPolyDataMapper *mapper2 = vtkPolyDataMapper::New();
> mapper2->SetInput(clip2->GetOutput());
> mapper2->SetScalarModeToUseCellData();
>
> vtkActor *actor2 = vtkActor::New();
> actor2->SetMapper(mapper2);
> actor2->AddPosition(12, 0, 0);
>
>
> // Display the 2 actors
> ren->AddActor(actor1);
> ren->AddActor(actor2);
> renWin->Render();
> iren->Start();
>
> // Clean up
> sp->Delete();
> geom->Delete();
> plane->Delete();
> clip1->Delete();
> mapper1->Delete();
> actor1->Delete();
> clip2->Delete();
> mapper2->Delete();
> actor2->Delete();
> ren->Delete();
> renWin->Delete();
> iren->Delete();
>}
--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------
More information about the vtkusers
mailing list