I have a vtkContourWidget and I wish to use a Live Wire method for drawing the lines. When I make a contour widget without the live wire stuff everything looks fine. However, when I add in the live wire stuff the line that is connecting two control points is not being shown. Below is a snippet of my code that deals with the live wire part (I'm writing in Java). Does anyone know why this is happening?<div>
<br></div><div>Thanks<br><div><br></div><div><div> vtkImageAnisotropicDiffusion3D diffusion = new vtkImageAnisotropicDiffusion3D();</div><div> diffusion.SetInput(imageData);</div><div><br></div><div> // Gradient magnitude for edges</div>
<div> vtkImageGradientMagnitude grad = new vtkImageGradientMagnitude();</div><div> grad.SetDimensionality(3);</div><div> grad.HandleBoundariesOn();</div><div> grad.SetInputConnection(diffusion.GetOutputPort());</div>
<div> grad.Update();</div><div><br></div><div> double[] range = grad.GetOutput().GetScalarRange();</div><div><br></div><div> // Invert the gradient magnitude so that low costs are</div><div> // associated with strong edges and scale from 0 to 1</div>
<div> vtkImageShiftScale gradInvert = new vtkImageShiftScale();</div><div> gradInvert.SetShift(-1.0*range[1]);</div><div> gradInvert.SetScale(1.0 / (range[0] - range[1]));</div><div> gradInvert.SetOutputScalarTypeToFloat();</div>
<div> gradInvert.SetInputConnection(grad.GetOutputPort());</div><div> gradInvert.Update();</div><div> gradInverseData = gradInvert.GetOutput();</div></div><div><br></div><div><div> vtkContourWidget contourWidget = new vtkContourWidget();</div>
<div> contourWidget.FollowCursorOn();</div><div><br></div><div> vtkOrientedGlyphContourRepresentation rep = new vtkOrientedGlyphContourRepresentation();</div><div> rep.GetLinesProperty().SetLineWidth(5);</div>
<div> rep.GetProperty().SetPointSize(6);</div><div> rep.SetWorldTolerance(0.000005);</div><div><br></div><div> // The contour rep requires a suitable point placer</div><div> vtkImageActorPointPlacer placer = new vtkImageActorPointPlacer();</div>
<div> placer.SetImageActor(imageViewer.GetImageActor());</div><div><br></div><div> rep.SetPointPlacer(placer);</div><div> // Reslice the data because the gradient only works in 2D</div><div> int[] dims = imageViewer.GetImageActor().GetDisplayExtent();</div>
<div> vtkImageReslice reslice = new vtkImageReslice();</div><div> reslice.SetInput(gradDataInverse);</div><div> reslice.SetOutputExtent(dims);</div><div> reslice.Update();</div><div><br></div><div>
// The line interpolator defines how intermediate points are</div><div> // generated between the representations nodes. This</div><div> // interpolator uses Dijkstra's shortest path algorithm.</div>
<div> vtkDijkstraImageContourLineInterpolator interpolator = new vtkDijkstraImageContourLineInterpolator();</div><div> interpolator.SetCostImage(reslice.GetOutput());</div><div><br></div><div> interpolator.GetDijkstraImageGeodesicPath().StopWhenEndReachedOn();</div>
<div> // prevent contour segments from overlapping</div><div> interpolator.GetDijkstraImageGeodesicPath().RepelPathFromVerticesOn();</div><div><br></div><div> // weights are scaled from 0 to 1 as are associated cost</div>
<div> // components</div><div> interpolator.GetDijkstraImageGeodesicPath().SetCurvatureWeight(0.15);</div><div> interpolator.GetDijkstraImageGeodesicPath().SetEdgeLengthWeight(0.8);</div><div> interpolator.GetDijkstraImageGeodesicPath().SetImageWeight(1.0);</div>
<div><br></div><div> rep.SetLineInterpolator(interpolator);</div><div> contourWidget.SetRepresentation(rep);</div></div></div><div> contourWidget.SetInteractor(panel.getRenWin().getIren());</div><div>
contourWidget.On();</div>