[vtkusers] Error in vtkAppendPolyData

Mathieu Malaterre mathieu.malaterre at kitware.com
Fri Feb 25 14:35:00 EST 2005


John,

	Could you please add this bug to the bug tracker. Simply go to :

http://vtk.org/Bug

	Login (or create an account). And enter a new bug. Please include your 
code (thank so much for providing it!). And assign the bug to me.

Thanks
Mathieu

Johnny C. Norris II wrote:
> Or maybe I'm just doing something wrong.
> 
> In my vis app, users can apply cutting planes to whatever they're 
> visualizing.  If they're visualizing the surface, then I use 
> vtkClipPolyData to clip the output of vtkDataSetSurfaceFilter, and 
> combine that with the output of a vtkCutter to cap the hole in the surface.
> 
> Anyway, something doesn't work right if the initial data has cell data 
> and 2D cells.  But vtkAppendPolyData doesn't process the cell data 
> correctly.  I've appended a code example that demonstrates the problem 
> (change the "#define CLIP" from 0 to 1 and recompile to see the error), 
> as well as two images illustrating the error.  Notice how the colors are 
> obviously incorrect in the clipped object.
> 
> I'm using the latest VTK from CVS, BTW.
> 
> Any help here would be greatly appreciated.
> 
> Thanks!
> John
> 
> 
> ------------------------------------------------------------------------
> 
> #include <vtkActor.h>
> #include <vtkAppendPolyData.h>
> #include <vtkCellData.h>
> #include <vtkClipPolyData.h>
> #include <vtkCutter.h>
> #include <vtkDataSetSurfaceFilter.h>
> #include <vtkFloatArray.h>
> #include <vtkOutlineFilter.h>
> #include <vtkPlane.h>
> #include <vtkPolyDataMapper.h>
> #include <vtkProperty.h>
> #include <vtkRenderer.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderWindowInteractor.h>
> #include <vtkScalarBarActor.h>
> #include <vtkScalarsToColors.h>
> #include <vtkStructuredPoints.h>
> 
> #define CLIP 0
> 
> int main()
> {
>   vtkFloatArray* pData = vtkFloatArray::New();
>   pData->SetNumberOfValues(5);
>   pData->SetValue(0, 0.f);
>   pData->SetValue(1, 1.f);
>   pData->SetValue(2, 2.f);
>   pData->SetValue(3, 1.f);
>   pData->SetValue(4, 0.f);
> 
>   vtkStructuredPoints* pGrid = vtkStructuredPoints::New();
>   pGrid->SetDimensions(6, 2, 2);
>   pGrid->GetCellData()->SetScalars(pData);
>   pData->Delete();
> 
>   vtkDataSetSurfaceFilter* pSurface = vtkDataSetSurfaceFilter::New();
>   pSurface->SetInput(pGrid);
> 
>   vtkPlane* pPlane = vtkPlane::New();
>   pPlane->SetOrigin(2.5, 0.0, 0.0);
>   pPlane->SetNormal(1.0, 0.0, 0.0);
> 
>   vtkClipPolyData* pClipper = vtkClipPolyData::New();
>   pClipper->SetInput(pSurface->GetOutput());
>   pClipper->SetClipFunction(pPlane);
> 
>   vtkCutter* pCutter = vtkCutter::New();
>   pCutter->SetInput(pSurface->GetOutput());
>   pCutter->SetCutFunction(pPlane);
>   pPlane->Delete();
> 
>   vtkAppendPolyData* pAppender = vtkAppendPolyData::New();
> #if CLIP
>   pAppender->AddInput(pClipper->GetOutput());
>   pAppender->AddInput(pCutter->GetOutput());
> #else
>   pAppender->AddInput(pSurface->GetOutput());
> #endif // CLIP
>   pSurface->Delete();
>   pClipper->Delete();
>   pCutter->Delete();
> 
>   vtkPolyDataMapper* pMapper = vtkPolyDataMapper::New();
>   pMapper->SetInput(pAppender->GetOutput());
>   pMapper->SetScalarRange(0.0, 2.0);
> 
>   vtkScalarBarActor* pSB = vtkScalarBarActor::New();
>   pMapper->CreateDefaultLookupTable();
>   pSB->SetLookupTable(pMapper->GetLookupTable());
> 
>   vtkActor* pActor = vtkActor::New();
>   pActor->SetMapper(pMapper);
>   pMapper->Delete();
> 
>   vtkRenderer* pRenderer = vtkRenderer::New();
>   pRenderer->AddActor(pActor);
>   pActor->Delete();
>   pRenderer->AddActor(pSB);
>   pSB->Delete();
> 
>   vtkOutlineFilter* pOutline = vtkOutlineFilter::New();
>   pOutline->SetInput(pGrid);
>   pGrid->Delete();
> 
>   pMapper = vtkPolyDataMapper::New();
>   pMapper->SetInput(pOutline->GetOutput());
>   pOutline->Delete();
> 
>   pActor = vtkActor::New();
>   pActor->SetMapper(pMapper);
>   pActor->GetProperty()->SetColor(1.0, 1.0, 1.0);
>   pMapper->Delete();
> 
>   pRenderer->AddActor(pActor);
>   pActor->Delete();
> 
>   vtkRenderWindow* pWindow = vtkRenderWindow::New();
>   pWindow->AddRenderer(pRenderer);
>   pRenderer->Delete();
> 
>   vtkRenderWindowInteractor* pInteractor = vtkRenderWindowInteractor::New();
>   pInteractor->SetRenderWindow(pWindow);
>   pWindow->Delete();
> 
>   pInteractor->Start();
> 
>   pInteractor->Delete();
> 
>   return 0;
> }
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list