[vtkusers] unable to pass globalids through vtk filters.

sreeram sayala at ni.com
Wed Jun 22 16:29:36 EDT 2016


I am having trouble passing global ids through vtk filters.  Particularly
vtkclipDataSet.  It appears that, the global copy flag is unset by the
filter.  Forcing it the flag to set in debugger does not help.

My global ids are vtkIdTypeArray.   I am setting them on vtkPointData.  Here
is the code snippet.

		vtkSmartPointer<vtkPoints> points =
		vtkSmartPointer<vtkPoints>::New();
	points->InsertNextPoint(0.0, 0.0, 0.0);
	points->InsertNextPoint(1.0, 0.0, 0.0);
	points->InsertNextPoint(0.0, 1.0, 0.0);
	auto arr = vtkSmartPointer<vtkIdTypeArray>::New();
	std::vector<vtkIdType> varr = { 0, 1, 2 };
	arr->SetArray(&varr[0], 3, 1);
	//	arr->SetName("myarr");
	vtkSmartPointer<vtkPolyData> pointsPolydata =
		vtkSmartPointer<vtkPolyData>::New();

	pointsPolydata->SetPoints(points);
	pointsPolydata->GetPointData()->SetGlobalIds(arr);

	pointsPolydata->GetPointData()->CopyGlobalIdsOn();

	//pointsPolydata->GetPointData()->SetActiveAttribute("arr",
vtkDataSetAttributes::GLOBALIDS);
	//	pointsPolydata->GetPointData()->CopyGlobalIdsOn();
	
	vtkSmartPointer<vtkVertexGlyphFilter> vertexFilter =
		vtkSmartPointer<vtkVertexGlyphFilter>::New();
#if VTK_MAJOR_VERSION <= 5
	vertexFilter->SetInputConnection(pointsPolydata->GetProducerPort());
#else
	vertexFilter->SetInputData(pointsPolydata);
#endif
	//vertexFilter->SetOutput(vertexFilter->GetInput());
	//auto n0 = vertexFilter->GetOutput()->GetPointData()->GetCopyGlobalIds();

	vertexFilter->Update();
	auto nCells = vertexFilter->GetOutput()->GetNumberOfCells();
	auto n = vertexFilter->GetOutput()->GetPointData()->GetGlobalIds();
	//	auto n2 =
vertexFilter->GetOutput()->GetPointData()->GetGlobalIds("myarr");

	vtkSmartPointer<vtkPolyData> polydata =
		vtkSmartPointer<vtkPolyData>::New();
	polydata->ShallowCopy(vertexFilter->GetOutput());
	auto n3 = polydata->GetPointData()->GetGlobalIds();
	
	// Setup colors
	unsigned char red[3] = { 255, 0, 0 };
	unsigned char green[3] = { 0, 255, 0 };
	unsigned char blue[3] = { 0, 0, 255 };

	vtkSmartPointer<vtkUnsignedCharArray> colors =
		vtkSmartPointer<vtkUnsignedCharArray>::New();
	colors->SetNumberOfComponents(3);
	colors->SetName("Colors");
	colors->InsertNextTupleValue(red);
	colors->InsertNextTupleValue(green);
	colors->InsertNextTupleValue(blue);

	polydata->GetPointData()->SetScalars(colors);


	auto pPlane = vtkSmartPointer<vtkPlane>::New();
	std::vector<double> vdNormal = { 0.1, 0, 0 };
	std::vector<double> vdOrigin = {0, 1.0, 0};

	pPlane->SetNormal(&vdNormal[0]);
	pPlane->SetOrigin(&vdOrigin[0]);

	auto pClipper = vtkSmartPointer<vtkClipDataSet>::New();
	pClipper->SetClipFunction(pPlane);
	pClipper->SetInputData(polydata);

vtkDataSet::SafeDownCast(pClipper->GetInput())->GetPointData()->CopyGlobalIdsOn();
	pClipper->GetOutput()->GetPointData()->CopyGlobalIdsOn();

	auto pPt = pClipper->GetOutput()->GetPointData();

vtkDataSet::SafeDownCast(pClipper->GetInput())->GetPointData()->Print(std::cout);
	pClipper->Update();
//	pClipper->GetOutput()->GetPointData()->CopyAllOn();
	pClipper->GetOutput()->GetPointData()->Print(std::cout);

	auto nnn0 =
vtkDataSet::SafeDownCast(pClipper->GetInput())->GetPointData()->GetGlobalIds();

	auto a =
vtkDataSet::SafeDownCast(pClipper->GetInput())->GetPointData()->GetCopyGlobalIds();
	auto a2 = pClipper->GetOutput()->GetPointData()->GetCopyGlobalIds();
	auto nnn = pClipper->GetOutput()->GetPointData()->GetGlobalIds();

The globalids' does pass through vertexFilter.  But does not pass through
the clip filter.

Any help is highly appreciated.

thanks,

Sreeram






--
View this message in context: http://vtk.1045678.n5.nabble.com/unable-to-pass-globalids-through-vtk-filters-tp5738851.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list