[vtkusers] using vtkClipClosedSurface() on a box crashes

kent myers dakota_63124 at yahoo.com
Mon May 25 19:18:58 EDT 2015


I am trying to clip a box constructed as a polydata mesh.  I have tried the
vtkClipPolyData class based on the quadric surface example in the following
link, but have not succeeded.

http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/SolidClip

I found the vtkClipClosedSurface class and it seems like exactly what I am
looking for, but I could not find any examples of how to use it.  The code
below shows my attempt.  It crashes when calling the Update() method. 
Without that call, I get no visible result.

Any help would be appreciated!

Kent

	private static void createBox() {
		float[] points = { 
				0.0f, 0.0f, 0.0f, 
				1.0f, 0.0f, 0.0f, 
				1.0f, 1.0f, 0.0f, 
				0.0f, 1.0f, 0.0f,
				0.0f, 0.0f, 1.0f, 
				1.0f, 0.0f, 1.0f, 
				1.0f, 1.0f, 1.0f, 
				0.0f, 1.0f, 1.0f,
				};
		int[] seq = { 
				4, 0, 1, 2, 3, 
				4, 1,5,6,2, 
				4, 5,4,7,6, 
				4, 4,0,3,7,
				4, 0,1,5,4,
				4, 3,2,6,7};


		// create a plane for clipping
		vtkPlane plane = new vtkPlane();
		plane.SetOrigin(0.0, 0.0, 0.5);
		plane.SetNormal(0, 0, 1);

		// create the box from points and sequence
		vtkPolyData polyData = new vtkPolyData();
		vtkPoints vtkPoints = new vtkPoints();
		vtkFloatArray d = new vtkFloatArray();
		d.SetJavaArray(points);
		d.SetNumberOfComponents(3);
		vtkPoints.SetData(d);
		polyData.SetPoints(vtkPoints);
		vtkCellArray vtkCells = new vtkCellArray();
		vtkIdTypeArray array = new vtkIdTypeArray();
		vtkIntArray intArray = new vtkIntArray();
		intArray.SetJavaArray(seq);
		array.DeepCopy(intArray);
		vtkCells.SetCells(seq.length, array);
		polyData.SetPolys(vtkCells);
		
		vtkClipClosedSurface clipClosedSurface = new vtkClipClosedSurface();
		vtkPlaneCollection planes = new vtkPlaneCollection();
		planes.AddItem(plane);
		clipClosedSurface.SetClippingPlanes(planes);
		clipClosedSurface.AddInputData(polyData);
		clipClosedSurface.Update();   // THIS CRASHES
		
		vtkDataSetMapper clipMapper = new vtkDataSetMapper();
		clipMapper.SetInputConnection(clipClosedSurface.GetOutputPort());

		boxActor = new vtkActor();
		boxActor.SetMapper(clipMapper);
		boxActor.GetProperty().SetColor(0.8900, 0.8100, 0.3400);

	}




--
View this message in context: http://vtk.1045678.n5.nabble.com/using-vtkClipClosedSurface-on-a-box-crashes-tp5731995.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list