# Intersection between two models (vtkMRMLModelNode)

**URL:** <https://discourse.slicer.org/t/intersection-between-two-models-vtkmrmlmodelnode/625>\
**Category:** Development\
**Created:** [July 5, 2017, 2:39am UTC](https://discourse.slicer.org/t/intersection-between-two-models-vtkmrmlmodelnode/625 "2017-07-05T02:39:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![robmbar](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@robmbar](https://discourse.slicer.org/u/robmbar)\
**Post date:** [July 5, 2017, 2:39am UTC](https://discourse.slicer.org/t/intersection-between-two-models-vtkmrmlmodelnode/625/1 "2017-07-05T02:39:28Z")

</div>

Hello Slicer developers,

I am looking for a way of updating a model, cutting the intersection of two models (vtkMRMLModelNode) as shown in the image.

 ![](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/1X/2199d4e2ab7153a78d454fef6d02611049ed8f9a.PNG)

Basically, I would like to remove the corner of the cube according to the intersection between the cube and the sphere. There is a Merge Module that joins the both models. Here, I want that to remove the intersection between the models. Do someone know how can I face it?

Thank you so much,  
Roberto Barbosa

---

<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:** [July 5, 2017, 2:44am UTC](https://discourse.slicer.org/t/intersection-between-two-models-vtkmrmlmodelnode/625/2 "2017-07-05T02:44:44Z")

</div>

Using `Segmentations` module: create a `Segmentation` node and import both models into it. Then go to `Segment editor` module and using `Logical operators` effect compute the intersection. Export the resulting segment to model node using `Segmentations` module.

You need to select a `Master volume` for the `Segment editor` module to work. If you don’t have any image then just load _any_ volume (anything in the `Sample data` module will do) and adjust its extent and resolution using Crop volumes mode.

---

<div class="post-metadata">

**Author:** ![robmbar](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@robmbar](https://discourse.slicer.org/u/robmbar)\
**Post date:** [July 5, 2017, 6:23pm UTC](https://discourse.slicer.org/t/intersection-between-two-models-vtkmrmlmodelnode/625/3 "2017-07-05T18:23:09Z")

</div>

Thank you so much for your quick reply and the important information provided, Andras Lasso. However, I am not being able to perform that. I followed your tips, I have downloaded the CTChest Sample Data once I did not have any volume, imported the both models into a segmentation node and selected the Segment Editor. Here, I selected the CTChest as Master volume and when I press the logical operators button appears this dialogue box window:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/f/df86a3a5eb9948326c0197253882ece51e286c55.png)

After that, the models are reshaped, as shown in the next image, and the operators don’t work.

 ![](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/1X/d7cd71e9ad247f022a443c9cb8af21bef94b6fd2.jpg)

---

<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:** [July 5, 2017, 7:28pm UTC](https://discourse.slicer.org/t/intersection-between-two-models-vtkmrmlmodelnode/625/4 "2017-07-05T19:28:02Z")

</div>

I’ve just tried it and it works well, but there are a few things to pay attention to:

- Use the latest nightly version.
- CTChest volume’s spacing is quite high (resolution is low) and they are different on each axis. You must use `Crop volume` module to make the spacing values smaller (finer resolution, by lowering `Spacing scale`) and same along all axes (by enabling `Isotropic spacing`). Adjust the extent of the volume to be just as big as you need it, by click-and-dragging sides of the ROI widget in slice views.
- After importing the models into segmentation node, hide or delete the models.
- In `Segment Editor` `Logical operators` effect, make sure you select one segment in the segment list above and another segment in the segment list (“Intersect with segment”) below.
- After clicking Apply, hide or delete the other segment so that you can clearly see the intersection.

---

<div class="post-metadata">

**Author:** ![robmbar](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@robmbar](https://discourse.slicer.org/u/robmbar)\
**Post date:** [July 6, 2017, 1:05am UTC](https://discourse.slicer.org/t/intersection-between-two-models-vtkmrmlmodelnode/625/5 "2017-07-06T01:05:01Z")

</div>

Thank you! Now it’s clear to me. It works well! I’ve played with the tools in the logical operators and I’ve concluded that the right operator to my application is the subtraction. Thus, I can remove from the cube, all the intersection volume and keep the sphere intact.  
It would be great to implement the python code to perform this procedure in my module. Could you point me in the right direction to achieve that?

---

<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:** [July 6, 2017, 1:58am UTC](https://discourse.slicer.org/t/intersection-between-two-models-vtkmrmlmodelnode/625/6 "2017-07-06T01:58:09Z")

</div>

Thanks for the update. I’m glad it worked. See this page for examples of how to use Segment Editor effects in your own module: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How\_to\_run\_segment\_editor\_effects\_from\_a\_script](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How_to_run_segment_editor_effects_from_a_script)
