<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi all,<br><br>I'm trying to calculate the circumference of the human head in 3D. I'm using VTK 5.10.1 and Python 2.7 64-bit. I want to calculate the intersection of a plane passing through certain point on the head. I then want to extract the boundary and calculate the length of this polyline. First, I want to visualize the boundary to make sure the extraction is working as expected.<br><br>As far as I understand, I can use vtkCutter to cut a slice from the original image. When I modify the vtkCutter ClipCow.py example, I can use vtkFeatureExtract to extract the boundary and write it to a .vtk file for visualization:<br><br> # Here we are cutting the cow. Cutting creates lines where the cut<br> # function intersects the model. (Clipping removes a portion of the<br> # model but the dimension of the data does not change.)<br> #<br> # The reason we are cutting is to generate a closed polygon at the<br> # boundary of the clipping process. The cutter generates line<br> # segments, the stripper then puts them together into polylines. We<br> # then pull a trick and define polygons using the closed line<br> # segments that the stripper created.<br> cutEdges = vtk.vtkCutter()<br> cutEdges.SetInputConnection(cow.GetOutputPort())<br> cutEdges.SetCutFunction(plane)<br> cutEdges.GenerateCutScalarsOn()<br> cutEdges.SetValue(0, 0.5)<br> cutStrips = vtk.vtkStripper()<br> cutStrips.SetInputConnection(cutEdges.GetOutputPort())<br> cutStrips.Update()<br> cutPoly = vtk.vtkPolyData()<br> cutPoly.SetPoints(cutStrips.GetOutput().GetPoints())<br> cutPoly.SetPolys(cutStrips.GetOutput().GetLines())<br><br> # Extract boundary from cutPoly<br> cutBoundary = vtk.vtkFeatureEdges()<br> cutBoundary.SetInput(cutPoly)<br> cutBoundary.Update()<br> # Write cut line to .vtk file<br> polyWriter = vtk.vtkPolyDataWriter()<br> polyWriter.SetInput(cutBoundary.GetOutput())<br> polyWriter.SetFileName("cutPoly.vtk")<br> polyWriter.Write()<br><br>The code works as intended. However, if I try using it with my own code, it won't read the surface data correctly:<br><br> # Circumference plane (used to cut)<br> circPlaneSource = vtk.vtkPlaneSource()<br> circPlaneSource.SetOrigin(G - <br> 150*self.midSagittalPlaneNormal)<br> circPlaneSource.SetPoint1(Op -<br> 150*self.midSagittalPlaneNormal)<br> circPlaneSource.SetPoint2(G +<br> 150*self.midSagittalPlaneNormal)<br> circPlaneSource.SetResolution(15, 15)<br> circPlaneSource.Update()<br><br> surface = vtk.vtkSTLReader()<br> surface.SetFileName(fileName)<br><br> # Cut a slice out of the surface and convert it to a PolyData object<br> cutEdges = vtk.vtkCutter()<br> cutEdges.SetInputConnection(surface.GetOutputPort())<br> cutEdges.SetCutFunction(circPlaneSource.GetOutput())<br> cutEdges.GenerateCutScalarsOn()<br> cutEdges.SetValue(0, 0.5)<br> cutStrips = vtk.vtkStripper()<br> cutStrips.SetInputConnection(cutEdges.GetOutputPort())<br> cutStrips.Update()<br> cutPoly = vtk.vtkPolyData()<br> cutPoly.SetPoints(cutStrips.GetOutput().GetPoints())<br> cutPoly.SetPolys(cutStrips.GetOutput().GetLines())<br> <br> # Extract boundary from cutPoly<br> cutBoundary = vtk.vtkFeatureEdges()<br> cutBoundary.SetInput(cutPoly)<br> cutBoundary.Update()<br><br> # Write cut line to .vtk file<br> polyWriter = vtk.vtkPolyDataWriter()<br> polyWriter.SetInput(cutBoundary.GetOutput())<br> polyWriter.SetFileName("test.vtk")<br> polyWriter.Write()<br><br>I don't get an error message, the code just hangs at the cutEdges.SetInputConnection(...). The only significant difference as far as I can tell is that I'm using an .stl file instead of a .g file. Shouldn't the outputport data from vtkSTLReader and vtkBYUReader be the same (a vtkAlgorithm object in this case)? <br><br>Though I've been using bits and pieces of vtk code over the past year, I'm still very unexperienced in VTK (and image processing in general). Am I supposed to extract the data from vtkSTLReader in a different way? Any help would be greatly appreciated.<br><br>Kind regards,<br><br>Daniel<br>                                            </div></body>
</html>