[vtkusers] vtkSelectPolydata does not work

pnt1614 minpu.code at gmail.com
Mon May 7 19:52:19 EDT 2018


I want to use the vtkSelectPolyData to extract a region inside a loop so
first I click many points to form a closed loop. After that, I use the
vtkSelectPolyData to extract a part inside this loop but in some cases the
result is empty. Is there anyway to check or debug this problem? or is this
a bug of VTK?

               vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();

		vtkSmartPointer<vtkPoints>  loop_points =
vtkSmartPointer<vtkPoints>::New();

                // m_clicked_points stores a list of points I clicked on a
stl model
		int n = m_clicked_points->GetNumberOfTuples();

		for (int i = 0; i < n; i++)
		{
			double p[3];
			m_clicked_points->GetTuple(i, p);
			loop_points->InsertNextPoint(p);			
		}

                // Insert the first point to close the loop
		double first_point[3];
		m_clicked_points->GetTuple(0, first_point);
		loop_points->InsertNextPoint(first_point);

		//------------------Extract--------------------
		vtkSmartPointer<vtkSelectPolyData> loop =
vtkSmartPointer<vtkSelectPolyData>::New();
		loop->SetLoop(loop_points);
		loop->SetInputData(stl_base->GetOutput());
		loop->GenerateUnselectedOutputOn();
		loop->Update();

		vtkSmartPointer<vtkActor> output_a = make_an_actor(loop->GetOutput());
		vtkSmartPointer<vtkActor> unselected_a =
make_an_actor(loop->GetUnselectedOutput());

		output_a->GetProperty()->SetRepresentationToWireframe();
		output_a->GetProperty()->SetColor(1, 0, 0);

		renderer->AddActor(output_a);
		renderer->AddActor(unselected_a);


                // m_vtkWindow is a vtkSmartPointer<vtkRenderWindow>
                m_vtkWindow->AddRenderer(renderer);
		m_vtkWindow->Render();



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list