# How to get first and last contact point between a vtkMRMLMarkupsCurveNode and a model?

**URL:** <https://discourse.slicer.org/t/how-to-get-first-and-last-contact-point-between-a-vtkmrmlmarkupscurvenode-and-a-model/37108>\
**Category:** Support\
**Created:** [June 30, 2024, 2:29pm UTC](https://discourse.slicer.org/t/how-to-get-first-and-last-contact-point-between-a-vtkmrmlmarkupscurvenode-and-a-model/37108 "2024-06-30T14:29:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [June 30, 2024, 2:29pm UTC](https://discourse.slicer.org/t/how-to-get-first-and-last-contact-point-between-a-vtkmrmlmarkupscurvenode-and-a-model/37108/1 "2024-06-30T14:29:09Z")

</div>

I have a bone model crossed by a curveNove. Any of the control points in curveNode are in model surface but I want to get them.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/3/632d0e607037e4af2c8dab8892661f2da81666b4.jpeg)

I´ve used vtk.vtkOBBTree() with IntersectWithLine for lines but I can´t find something similar for curves.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [June 30, 2024, 7:49pm UTC](https://discourse.slicer.org/t/how-to-get-first-and-last-contact-point-between-a-vtkmrmlmarkupscurvenode-and-a-model/37108/2 "2024-06-30T19:49:14Z")

</div>

You may investigate vtkSelectEnclosedPoints and/or vtkExtractEnclosedPoints to get all points from the curve that are inside your bone segment.

You must convert the segment to polydata, and get the curve as polydata also (GetCurveWorld()) as inputs to the mentioned classes. With vtkExtractEnclosedPoints, the first and last points of the output are what you are expecting. You might want to add more points to the curve’s polydata using vtkPolyDataPointSampler.

This approach is valid in the simple case you are exposing: a simple curve, a simple segment, one entry and one exit. If the curve zigzags through the segment, this doesn’t hold.

![entry_exit_locations](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/e/6ee1d026d368e1efcef84f904b0d63bd222a794e.png)
