[vtkusers] Hide/Make Cells Invisible in vtkpolydata

Alex Malyushytskyy alexmalvtk at gmail.com
Tue Mar 5 21:03:13 EST 2013


I have not tried it but I think you can assign transparency to individual cells
by using RGBA cell scalars.
But I am not sure how convenient this if you need different coloring technique.
At least I expect some difficulties if you for example want to color
cells by other array.
Using such approach you would have to change colors (RGB) manually .

I guess other common approach would be to add filter into pipeline
which would extract only required portion of the geometry.
Filters and way how cells are identified may vary.
For example you could probably use code similar to below which splits
polydata on two parts based on ids.
You would have to fill array ids accordingly and then use filtered
polydata in your pipeline.
You may chose to use different filters ( for example vtkExtractPolyData ) .

Another link which might help
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/ExtractSelection

Regards,
     Alex

P.S, Code example is below

bool stlModifier::processVisivility( vtkPolyData* poly)
{
        vtkPolyData* polyOut1 = poly;
	vtkPolyData* polyOut2 = NULL;

	vtkSmartPointer<vtkPolyData> selected;
	vtkSmartPointer<vtkPolyData> notSelected;

		vtkSmartPointer<vtkIdTypeArray> ids = vtkSmartPointer<vtkIdTypeArray>::New();
		ids->SetNumberOfComponents(1);

// ids of cells
        	ids->InsertNextValue(0);
		ids->InsertNextValue(5);
...

			vtkSmartPointer<vtkSelectionNode> selectionNode =
vtkSmartPointer<vtkSelectionNode>::New();
			selectionNode->SetFieldType(vtkSelectionNode::CELL);
			selectionNode->SetContentType(vtkSelectionNode::INDICES);
			selectionNode->SetSelectionList(ids);

 			vtkSmartPointer<vtkSelection> selection =
vtkSmartPointer<vtkSelection>::New();
			selection->AddNode(selectionNode);

			vtkSmartPointer<vtkExtractSelection> extractSelection;
			extractSelection = vtkSmartPointer<vtkExtractSelection>::New();
			extractSelection->SetInput(0,  poly );
			extractSelection->SetInput(1, selection);

			vtkSmartPointer<vtkDataSetSurfaceFilter> filter =
vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
			filter->UseStripsOff( );
			filter->SetInputConnection( extractSelection->GetOutputPort() );
		
			extractSelection->Update();
			filter->Update();

			selected = vtkSmartPointer<vtkPolyData>::New();
			selected->ShallowCopy( filter->GetOutput() );
			polyOut2 = selected.GetPointer();

			selectionNode->GetProperties()->Set(vtkSelectionNode::INVERSE(),
1); //invert the selection
			extractSelection->Update();
			filter->Update();

			notSelected = vtkSmartPointer<vtkPolyData>::New();
			notSelected->ShallowCopy( filter->GetOutput() );
			polyOut1 = notSelected.GetPointer();

On Mon, Mar 4, 2013 at 12:20 AM, Petr Vokac <vok at ujv.cz> wrote:
> Did you try to set opacity to zero instead?
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Hide-Make-Cells-Invisible-in-vtkpolydata-tp5718950p5718966.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK 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