[vtkusers] Clipping PolyData after vtkPolyDataConnectivityFilter problem

Alex Malyushytskyy alexmalvtk at gmail.com
Thu Aug 11 00:05:26 EDT 2011


I need to do the following manipulation with polydata:
- split by connectivity
- split by array values ( point and cell arrays )
- do something to each part.

Everything seems work, except splitting by array.
The problem is that I am trying to achieve it
with multiple clipping.

But first clipping with vtkClipPolyData
does not pass "RegionId" array  it gets from the input
(vtkPolyDataConnectivityFilter output)

Even though it does preserve cell data array which was added to poly
data before connectivity filter.

Questions is -  why point data array is not passed (with clipping ) to
the vtkClipPolyData output?
How to clip poly data properly limiting lower and upper of scalar
without multiple filters?

Code below demonstrates a problem by clipping output of
vtkPolyDataConnectivityFilter.

Before clip->Update();  there is 1 point array and 1 cell array,
after clipping   there is no point array but there is 1 cell array,

Regards,
  Alex


vtkAlgorithmOutput* inputConnection = .....


vtkSmartPointer<vtkPolyDataConnectivityFilter> connectivityFilter =
vtkSmartPointer<vtkPolyDataConnectivityFilter>::New();
connectivityFilter->SetInputConnection( inputConnection  );
connectivityFilter->SetExtractionModeToAllRegions();
connectivityFilter->ColorRegionsOn ();
connectivityFilter->Update();

int regions = connectivityFilter->GetNumberOfExtractedRegions();

if ( regions > 1 )
{
	vtkIndent indent( 1 );
	connectivityFilter->GetOutput()->GetPointData()->SetActiveScalars(
"RegionId" );
        connectivityFilter->GetOutput()->PrintSelf(std::cout, indent);
	qDebug() << "connectivityFilter cells = " <<
connectivityFilter->GetOutput()->GetNumberOfCells()  << endl;

	for ( int i=0; i < regions; i ++ )
	{
		qDebug() << "Before first clipping " << endl;
//output = 1
		qDebug() << "Number of PointData arrays: " <<
connectivityFilter->GetOutput()->GetPointData()->GetNumberOfArrays()
<< endl;
//output = 1
		qDebug() << "Number of Cell data arrays: " <<
connectivityFilter->GetOutput()->GetCellData()->GetNumberOfArrays() <<
endl; // returns 1


		vtkSmartPointer<vtkClipPolyData> clip =
vtkSmartPointer<vtkClipPolyData>::New();
		clip->SetInput( connectivityFilter->GetOutput() );
		clip->InsideOutOff();
		clip->SetValue( (float) i - 0.1 );
		clip->Update();

		qDebug() << "After first clipping vtkClipPolyData" << endl;
//output = 0 // WHY?
		qDebug() << "Number of PointData arrays: " <<
clip->GetOutput()->GetPointData()->GetNumberOfArrays() << endl;
//output = 1
		qDebug() << "Number of Cell data arrays: " <<
clip->GetOutput()->GetCellData()->GetNumberOfArrays() << endl;

		qDebug() << "After first clipping connectivityFilter output" << endl;
//output = 1
		qDebug() << "Number of PointData arrays: " <<
connectivityFilter->GetOutput()->GetPointData()->GetNumberOfArrays()
<< endl;
//output = 1
		qDebug() << "Number of Cell data arrays: " <<
connectivityFilter->GetOutput()->GetCellData()->GetNumberOfArrays() <<
endl;

		vtkSmartPointer<vtkClipPolyData> clipInsideOut =
vtkSmartPointer<vtkClipPolyData>::New();
		clipInsideOut->SetInput(clip->GetOutput() );
		clipInsideOut->InsideOutOn();

		clipInsideOut->SetValue( (float) i + 0.1 );
		clipInsideOut->Update();
		clipInsideOut->GetOutput()->PrintSelf(std::cout, indent);

....................

	}



}



More information about the vtkusers mailing list