How to draw lines on surface

I’m trying to draw lines on mesh , like this(I’m using vtkIntersectionPolyDataFilter now, but Inefficient)

class vtkProjectedTerrainPath need a vtkImageData input. How can I get it by converting the vtkPolyData, or any other ways to achive that effect? thanks!

Hi - do your lines represent intersections with your surface? If so, vtkIntersectionPolyDataFilter seems appropriate. I searched for other examples, but didn’t find anything enlightening.

Thanks for answering! The surface actor update every second,but drawing lines costs 0.5 second(when using vtkIntersectionPolyDataFilter),vtkProjectedTerrainPath maybe a better way, but I don’t know how to

There is one Python example, it didn’t look too mysterious. The author created a polyline, terrainPaths and set it as the input data. They then went on to use the Mt. St. Helens data as the source connection. I haven’t tried this yet, and I gather that there are several modes that can be used.

...
projectedPaths = vtk.vtkProjectedTerrainPath()
projectedPaths.SetInputData(terrainPaths)
projectedPaths.SetSourceConnection(demReader.GetOutputPort())
projectedPaths.SetHeightOffset(25)
projectedPaths.SetHeightTolerance(5)
projectedPaths.SetProjectionModeToNonOccluded()
projectedPaths.SetProjectionModeToHug()
...

Most of the time users wants to have an editable curve, not just one that can only be drawn once. So, I would recommend what we do in 3D Slicer: specify a curve by dropping (and moving) control points on the surface and project the interpolated curve points to the surface.

It is all implemented with VTK-based classes here. The curve generator and projection classes are in the MRML folder.

1 Like

Hello, could you please point out the specific function of generating lines through points in which cxx file? There are so many files that it’s hard to make sense of them.

I cannot be more specific without spending a lot of time with it. The full source code is there and you can also build Slicer and run the code line by line in a debugger. If it looks too much or too complicated then you light consider using Slicer (or Para iew or other VTK-based open-source platforms) as your application framework. Then you don’t need to “extract” code and you can also save enormous amount of time on development and maintenance of all basic features like this.

I looked at the source code, but I have some questions that I would like you to answer.
I guess the point on the spline curve is attached to the surface by vtkMRMLMarkupsCurveNode: : ConstrainPointsToSurface function.
But I don’t know what function parameter normalVectors stands for, could you please explain?

\param normalVectors The normals for the originalPoints.


Is normal the N represented in the figure?

To interactively create the lines, you could leverage the vtkSplineWidget along with a vtkPolygonalSurfacePointPlacer.

Hi, do you know how to implement the method of generating curves on surface mentioned by Lasso in the video?

I used the method provided by Lasso, although the curves did not fit the model perfectly under the model constraints. I think it takes more work if you want to draw smooth curves on the surface of the model.
Now I see doing well - > url: https://blog.csdn.net/qq_18566467/article/details/134580805