[vtkusers] collision detection with vtk?

-Daniel- ich_daniel at habmalnefrage.de
Sun Aug 25 06:00:10 EDT 2013


Unfortunately are some methods not available in Java.
The vtkCellLocator provides only / FindCell(double[]) / and /
FindCellsAlongLine(double[], double[], double, vtkIdList) / .

Now I use following code:
///..
vtkActor movedActor;
vtkPolyData movedPolydata;

vtkTransform transform = new vtkTransform();
transform.SetMatrix(movedActor.GetMatrix());

vtkTransformPolyDataFilter transformPolyData = new
vtkTransformPolyDataFilter();
transformPolyData.SetInputData(movedPolydata);
transformPolyData.SetTransform(transform);
transformPolyData.Update();
				
vtkActor actor = constantActors;
actor.SetPosition(centeredPosition);
		
vtkSelectEnclosedPoints selectEnclosedPoints = new
vtkSelectEnclosedPoints();
selectEnclosedPoints.SetInputConnection(transformPolyData.GetOutputPort());
selectEnclosedPoints.SetSurfaceData(actorToPolyData(actor)); 
selectEnclosedPoints.Update();

vtkDataArray insideArray = (vtkDataArray) selectEnclosedPoints
	.GetOutput().GetPointData().GetArray("SelectedPoints");

for (int i = 0; i < insideArray.GetNumberOfTuples(); i++) {
	if (insideArray.GetComponent(i, 0) == 1) {
		 // Collision!
                ..
		 break;
	 }
}
..

//by moving the movedActor then
transform.SetMatrix(movedActor.GetMatrix());
		
selectEnclosedPoints.Update();
vtkDataArray insideArray = (vtkDataArray) selectEnclosedPoints
		.GetOutput().GetPointData().GetArray("SelectedPoints");

for (int i = 0; i < insideArray.GetNumberOfTuples(); i++) {
	if (insideArray.GetComponent(i, 0) == 1) {
		// Collision!
                ..
		break;
	}
} /


It is a little bit faster than before, but isn't ever correct.





--
View this message in context: http://vtk.1045678.n5.nabble.com/collision-detection-with-vtk-tp5722845p5723016.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list