# Why "closed curve" cannot generate Baffle model in Baffle Planner module?

**URL:** <https://discourse.slicer.org/t/why-closed-curve-cannot-generate-baffle-model-in-baffle-planner-module/19076>\
**Category:** Support\
**Created:** [August 5, 2021, 12:05pm UTC](https://discourse.slicer.org/t/why-closed-curve-cannot-generate-baffle-model-in-baffle-planner-module/19076 "2021-08-05T12:05:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![StephenLeePeng](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/stephenleepeng/32/11892_2.png) [@StephenLeePeng](https://discourse.slicer.org/u/StephenLeePeng)\
**Post date:** [August 5, 2021, 12:05pm UTC](https://discourse.slicer.org/t/why-closed-curve-cannot-generate-baffle-model-in-baffle-planner-module/19076/1 "2021-08-05T12:05:31Z")

</div>

Operating system: Ubuntu 18.04  
Slicer version: self-build, Slicer 4.13.0  
Expected behavior:  
First I load a stl file, then I switch to “Markups” module, and draw a closed curve around the stl model. Then I switch to “Baffle Planner module”, and select the drawed closed curve as Input curve, and select “Create new Model as …”, then a surface will generate automatically.

But, If in Markups module, I select draw a closed curve, by selecting curve type to “Shortest distance on surface” and stl as Model Node. The closed curve drawed will attch on the stl model. Then when I switch to Baffle Planner module, and select the latest curve, and select “Create new Model as …” in Baffle modle, but there is no new Baffle model generated, and there exist no error and warnings in the output.

So, why the new baffle model cannot generate in this condition? How to solve this problem?

 ![lALPDiQ3PZO1ZPTNA7jNBPc_1271_952](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/9/7959b08e45118cf6269ceba41bb92330117cc0d9.jpeg)

Above picture is baffle model generated in the first condition.

 ![lALPDgfLSG2tVdDNAlHNBL4_1214_593](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/d/0dda554d2eb6b838c46afe785e3841507708737e.png)  
Above picture is generate failed in the second condition when I draw closed curve attach on the stl model.

---

<div class="post-metadata">

**Author:** ![StephenLeePeng](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/stephenleepeng/32/11892_2.png) [@StephenLeePeng](https://discourse.slicer.org/u/StephenLeePeng)\
**Post date:** [August 6, 2021, 3:37am UTC](https://discourse.slicer.org/t/why-closed-curve-cannot-generate-baffle-model-in-baffle-planner-module/19076/2 "2021-08-06T03:37:39Z")

</div>

Hi, @lassoan , could you help me explain, why the Baffle Model can’t generate automatically when I draw a closed curve attch on the stl model in the second picture.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 7, 2021, 12:09pm UTC](https://discourse.slicer.org/t/why-closed-curve-cannot-generate-baffle-model-in-baffle-planner-module/19076/3 "2021-08-07T12:09:29Z")

</div>

Could you share the scene saved as an .mrb file? (upload somewhere and post the link here)

---

<div class="post-metadata">

**Author:** ![StephenLeePeng](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/stephenleepeng/32/11892_2.png) [@StephenLeePeng](https://discourse.slicer.org/u/StephenLeePeng)\
**Post date:** [August 9, 2021, 6:11am UTC](https://discourse.slicer.org/t/why-closed-curve-cannot-generate-baffle-model-in-baffle-planner-module/19076/4 "2021-08-09T06:11:56Z")

</div>

Thank you for reply.  
I have uploaded the Slicer mrml file, and related stl, Baffle.vtk and so on, wrapped into a zip file, named: SurfaceCutDemo-0809.zip. Please down the zip file via: [SurfaceCutDemo-0809.zip - Google Drive](https://drive.google.com/file/d/1EiQwZmUIuOgN6wj4A0iB1-nZVUk96SQi/view)  
Expect to your reply.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 9, 2021, 6:44pm UTC](https://discourse.slicer.org/t/why-closed-curve-cannot-generate-baffle-model-in-baffle-planner-module/19076/5 "2021-08-09T18:44:06Z")

</div>

Thank you, the sample data set helped to understand the problem. The issue is that the “Shortest distance on surface” method connects mesh points and therefore the curve is very jagged and the points are very much out of plane, and so it is very hard to generate a triangulated surface for it (that is required for area measurement).

You can get a better-behaved, smooth curve if you keep curve type = spline, and you resample the control points on the surface using “Resample” section. You just need to make sure that the control points are evenly distributed along the vessel.

SlicerVMTK extension can compute diameter of the airways, it provides minimum inscribed sphere radius for all points of the centerline curve.

Recently @chir.set added true (free-form) cross-sectional area computation to “Centerline metrics” module in SlicerVMTK, which will be available from tomorrow for latest Slicer Preview Releases (and maybe latest Slicer Stable Release, too). There are a few things to improve, which may make the cross-section more accurate - you can track the status of these improvements here:

> <https://github.com/vmtk/SlicerExtension-VMTK/issues/35>
>
> This is a follow-up to improve features introduced in https://github.com/vmtk/Sl…icerExtension-VMTK/pull/32
> 
> \- \[\] "Segmentation" section should be renamed to Cross-section area measurement
> \- \[\] "Surface area" should be renamed to "Cross-sectional area"
> \- \[\] "Derived diameter" should be renamed to "Circular equivalent diameter"
> \- \[\] "VMTK" diameter should be renamed to "Minimum inscribed sphere diameter" (or MIS diameter for short, and put the full word in tooltip). Difference and ratio compared to circular equivalent diameter should be made more clear. For example, a complete line could look like this: \`MIS diameter: 16.80mm (CE diameter +2.4mm, +18%)\`
> \- \[\] Allow using centerline curve as centerline input (as opposed to just model nodes). In Slicer Preview Releases, the MIS radius values are saved in the curve node (can be used for coloring, saved in the markups json file, etc.) and can be accessed as a numpy like this: \`a=slicer.util.arrayFromMarkupsControlPointData(curveNode, 'Radius')\`
> \- \[\] Allow using model node as input for cross-section area measurement instead of just segmentation node, if it can be easily made work with surface models (e.g., we don't rely on labelmap representations).
> \- \[\] Computation of cross-sections does not seem to be very robust: spacing between planes is quite large, non-uniform, and their orientation is changing quite randomly. The degree of these problems may depend on the resolution of the input mesh. For example for the mesh in this scene, things are quite bad: https://1drv.ms/u/s!Arm\_AFxB9yqHxfZSIMXrFc2FDfTe8Q?e=XYC420 (see image below)
> 
> !\[image\](https://user-images.githubusercontent.com/307929/128756086-7922a866-4cc1-4121-9cee-c2631b05b8c4.png)

---

<div class="post-metadata">

**Author:** ![StephenLeePeng](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/stephenleepeng/32/11892_2.png) [@StephenLeePeng](https://discourse.slicer.org/u/StephenLeePeng)\
**Post date:** [August 10, 2021, 11:54am UTC](https://discourse.slicer.org/t/why-closed-curve-cannot-generate-baffle-model-in-baffle-planner-module/19076/6 "2021-08-10T11:54:02Z")

</div>

Thank you for your reply.  
But when I change the curve type as ‘spline’, and use Resample section, and select  
“Output node” as ‘Overwrite current node’,  
“Constrain points to surface” to the loaded stl model.  
And then I switch to Baffle Planner module, and select closed curve as Input curve, but when I select “Create new model” in the Baffle model. But no Baffle surface generate automaticlly.  
So I think “the curve is too jagged to cause no Baffle surface generate” is not the main reason, maybe because the curve controlPoint or the connect line is inside the stl model.

attched zip file is mrml file stored. [SurfaceCutDemo-0810.zip - Google Drive](https://drive.google.com/file/d/1HJMqXp7izbRHkW8U9UnwaDiY5igq2o6w/view?usp=sharing)

 ![0810-001](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/8/782a382017f3e9874f31da4be8a2198ac2b01fd3.png)

 ![0810-002](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/f/7f96f5b6680db253b26c26abe1d6f66a3ac38b96.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 10, 2021, 4:39pm UTC](https://discourse.slicer.org/t/why-closed-curve-cannot-generate-baffle-model-in-baffle-planner-module/19076/7 "2021-08-10T16:39:30Z")

</div>

We use two different approaches in Slicer for fitting closed surface on an arbitrary closed curve: “ProjectWarp” and “DiskWarp”. They are described [here](https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Markups/Logic/vtkSlicerMarkupsLogic.h#L218-L250). Baffle planner uses DiskWarp, which is more tolerant to out-of-plane points, but only works for quasi-circular contours. Markups closed curves use “ProjectWarp”, which works for arbitrarily concave shapes, but more sensitive to contour points being out of plane.

If you find the surface computed by baffle planner appropriate then you can go to Models module and get the surface are in the Information section:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/b/8b3b9c1f8d5593bd7d8a7ad9636a9ecf55f72540.png)
