# Cutter Output curve to mesh

**URL:** <https://discourse.vtk.org/t/cutter-output-curve-to-mesh/5116>\
**Category:** Development\
**Created:** [February 1, 2021, 5:35pm UTC](https://discourse.vtk.org/t/cutter-output-curve-to-mesh/5116 "2021-02-01T17:35:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anish\_Basnet](https://discourse.vtk.org/user_avatar/discourse.vtk.org/anish_basnet/32/2676_2.png) [@Anish\_Basnet](https://discourse.vtk.org/u/Anish_Basnet)\
**Post date:** [February 1, 2021, 5:35pm UTC](https://discourse.vtk.org/t/cutter-output-curve-to-mesh/5116/1 "2021-02-01T17:35:05Z")

</div>

Hello everyone,  
Is it possible to convert the output curve of a vtkCutter class to a mesh? I wanted to compute curvatures but vtkCurvatures only takes a polydata mesh as input. I tried using vtkDelaunay2D but the mesh is irregular. And I tried to smooth the mesh using vtkWindowedSincPolyDataFilter but the filter does not give the result that I want. I also played with the number of iterations method. I would like to get the points from the curve where the curvature changes i.e. from convex to concave or concave to convex.

 ![cutterOutput](https://discourse.vtk.org/uploads/default/original/2X/6/6ebb2300df1e9f711768da341968db92cc2d5e1c.png)

---

<div class="post-metadata">

**Author:** ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)\
**Post date:** [February 2, 2021, 1:12am UTC](https://discourse.vtk.org/t/cutter-output-curve-to-mesh/5116/2 "2021-02-02T01:12:46Z")

</div>

…maybe there’s some more clever way… one possibility is to fit analytically (superfast) a circle to the line locally and look at the cross product to its center to get the sign of the curvature:

```python
import numpy as np
from vedo import *

shape = Spline([
                [0.0, 0.0],
                [1.0, 0.0],
                [1.1, 4.0],
                [3.0, 1.5],
               ],
                res=100,
                smooth=0,
              ).lineWidth(4)

points = shape.points()
fitpts=[]
circles=[]
curvs=[]
n=4
for i in range(shape.NPoints()-n):
    pts = points[i:i+n]
    cx, cy, R = fitCircle2D(pts)
    z = np.cross(pts[-1]-pts[0], pts[0]-[cx,cy,0])[2]
    curvs.append(np.sqrt(R))
    if R<1:
        fitpts.append([cx,cy])
        circle = Circle([cx, cy], r=R).wireframe().color(int(z+1))
        circles.append(circle)
curvs += [curvs[-1]]*n

shape.cmap('jet', curvs).addScalarBar(title='\sqrtR')
show(shape, circles, Points(fitpts), axes=1)

print(type(shape.polydata()))

```

 ![Screenshot from 2021-02-02 01-51-02](https://discourse.vtk.org/uploads/default/original/2X/5/5693e6afda008a064836422341b7e2eef8b7271e.png)

check out the algorithm [here](https://github.com/marcomusy/vedo/blob/b2d34999d45e9802b2351850707b55d51f072218/vedo/utils.py#L560).

---

<div class="post-metadata">

**Author:** ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)\
**Post date:** [February 2, 2021, 2:49am UTC](https://discourse.vtk.org/t/cutter-output-curve-to-mesh/5116/3 "2021-02-02T02:49:43Z")

</div>

I see that you use 3D Slicer. We have recently added measurements for markups. Curve measurements include curvature (we implemented a [new VTK class for curve curvature computation](https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Markups/MRML/vtkCurveMeasurementsCalculator.h)). All you need to run vtkCutter output through a [vtkStripper](https://vtk.org/doc/nightly/html/classvtkStripper.html) to order the random line segments into a continuous curve then set points of the resulting polydata as input to the curve node in Slicer - about 8-10 lines of Python code in total. Or, if you work in C++ then you can take the vtkCurveMeasurementCalculator class from Slicer (it does not have any Slicer dependency), and use it in your software.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/7/7ec4f301670abae7de7bc478f123f5245de0d54c.png)

---

<div class="post-metadata">

**Author:** ![Anish\_Basnet](https://discourse.vtk.org/user_avatar/discourse.vtk.org/anish_basnet/32/2676_2.png) [@Anish\_Basnet](https://discourse.vtk.org/u/Anish_Basnet)\
**Post date:** [February 2, 2021, 3:20pm UTC](https://discourse.vtk.org/t/cutter-output-curve-to-mesh/5116/5 "2021-02-02T15:20:56Z")

</div>

Hello @lassoan,  
Thank you for the reply! I did not see any difference in the image of the curve that I attached earlier with the vtkStripper class. Is there any way to get the scalars(curvatures) and determine the RAS coordinates of a point where the sign of the curvature is changed? I saved the obtained curvatures from the vtkCurvatures class in a vtkDoubleArray and iterated over the array and determined the possible points(RAS). Is it somehow possible to do the same thing with the vtkCurveMeasurementCalculator class?  
 ![download](https://discourse.vtk.org/uploads/default/original/2X/6/60b02c79dfc165acdd67705b6e87a07830506c0c.png)

Best regards,  
Anish

---

<div class="post-metadata">

**Author:** ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)\
**Post date:** [February 2, 2021, 4:22pm UTC](https://discourse.vtk.org/t/cutter-output-curve-to-mesh/5116/6 "2021-02-02T16:22:43Z")

</div>

vtkCurvature is for surfaces, not curves. Instead, you can use vtkCurveMeasurementCalculator class in Slicer or similar VTK classes in VMTK, etc. I would assume there are also tons of computational geometry packages in Python that can compute curvature of curves.
