[vtkusers] help with vtkPointLocator

M.Hardikar at asu.edu M.Hardikar at asu.edu
Sun Jun 9 02:08:15 EDT 2002


following is the code that I am using:
pSTL_poly is the source that I have populated using STLreader and the input
data is a sheet metal body in STL format.
------------------------------
vtkPointLocator *pointLocator = vtkPointLocator::New();
	pointLocator->SetDataSet(pSTL_poly->GetOutput()->GetPoints());
	pointLocator->BuildLocator();

	vtkSphereSource *spot = vtkSphereSource::New();
    spot->SetPhiResolution(6);
    spot->SetThetaResolution(6);
    spot->SetRadius(0.1);
  	vtkPolyDataMapper *spotMapper = vtkPolyDataMapper::New();
    spotMapper->SetInput(spot->GetOutput());

	// Find closest point
	vtkIdType ptId;
	float dist;
	float p1[] = {2.0, 1.0, 3.0};
	p1[0] = med->get_X_component(); p1[1] = med->get_Y_component(); p1[2]
= med->get_Z_component();
	ptId = pointLocator->FindClosestPoint(p1);
	vtkActor *closestPointActor = vtkActor::New();
	closestPointActor->SetMapper(spotMapper);

closestPointActor->SetPosition(pSTL_poly->GetOutput()->GetPoints()->GetPoint(ptId));
	closestPointActor->GetProperty()->SetColor(0.0, 1.0, 0.0);

	GetProps()->AddItem(closestPointActor);

--------------------------------------------

i am getting follwoing error and program crashes:
ERROR: c:\martink\vtk40\VTK\Common\vtkPointLocator.cxx, line 975
vtkPointLocator [0x00E7A4C0] : No points to subdivide

Help..

Thanks






More information about the vtkusers mailing list