# Visualizing 3D polydata of the model in 2D slice view

**URL:** <https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010>\
**Category:** Development\
**Created:** [September 6, 2018, 8:37pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010 "2018-09-06T20:37:44Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Feodor](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@Feodor](https://discourse.slicer.org/u/Feodor)\
**Post date:** [September 6, 2018, 8:37pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/1 "2018-09-06T20:37:44Z")

</div>

Hi all.  
The idea is to display the 3d model in the same way as its intersection with the slice plane, that is each 2D slice view display the 3d model from its own “angle of view”.  
I’m trying to add the polydata of the vtkMRMLModelNode to the visualizing pipeline of the vtkMRMLModelSliceDisplayableManager class simply by adding the 3d actor and vtkPolyDataMapper.  
The only TransformFilter I’m using is the ModelWarper - the one that is used for transforming the 2d intersection polydata. The rendered polydata seems to be inproperly positioned and oriented as can be seen on the screenshot below.

Could anyone please advise me which transform should I use to achieve the initial goal? Thank you in advance.

 ![falsely_positioned_model](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/b/0bb4d20d0171923009b26351562c8f04df8e5eaa.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:** [September 6, 2018, 11:48pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/2 "2018-09-06T23:48:14Z")

</div>

3D views are supposed to be used for displaying 3D content. If you want to show mixed 2D and 3D (e.g., image slice and 3D content) then you also need to use 3D views. What is your end goal? Augmented reality display?

---

<div class="post-metadata">

**Author:** ![Feodor](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@Feodor](https://discourse.slicer.org/u/Feodor)\
**Post date:** [September 7, 2018, 12:46pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/3 "2018-09-07T12:46:24Z")

</div>

Hi Andras!

> [@lassoan](#):
>
> What is your end goal? Augmented reality display?

No, the goal is to display the full 3d model behind its intersection with the slice plane. The screenshot in my initial post shows that 3D content can be shown within 2D view. The only problem that I’m currently facing is the absence of the transformation matrix which should be applied to the polydata.  
My guess is that it should be in form of the **RASToXY** , but it would give me the display coordinates, which is unsuitable in case of 3D mapper/actor.

---

<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:** [September 7, 2018, 1:14pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/4 "2018-09-07T13:14:07Z")

</div>

> [@Feodor](#):
>
> the goal is to display the full 3d model behind its intersection with the slice plane

You are not supposed to add 3D actors to slice views. If you want to work with 3D actors then you need to use 3D views.

You can display clipped models in the 3D view (see clipping section in Models module). You can also show slice view in 3D views (click eye icon of the slice view to enable this). If these are not enough then tell a bit more about what exactly you would like to show (an example rendering or photoshopped image of what you would like to see would help a lot).

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 7, 2018, 1:43pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/5 "2018-09-07T13:43:51Z")

</div>

> [@lassoan](#):
>
> tell a bit more about what exactly you would like to show (an example rendering or photoshopped image of what you would like to see would help a lot).

Yes, please! I’m quite curious now.

---

<div class="post-metadata">

**Author:** ![Feodor](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@Feodor](https://discourse.slicer.org/u/Feodor)\
**Post date:** [September 7, 2018, 2:14pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/6 "2018-09-07T14:14:24Z")

</div>

Hi Csaba!

> [@cpinter](#):
>
> Yes, please! I’m quite curious now.

The initial goal is to have a dental implants viewer based on Slicer (as it already has the radiological background for working in several view projections). Below is the snapshot of the UI of the **Blue Sky Plan** dental software which has the exact functionality that I’m trying to achieve for displaying both the 3d model of the implant and its intersection with the current slice (overlayed) within the 2D slice view:

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

To achieve the result shown on the snapshot from my initial post, I had to modify the vtkMRMLSliceModelDisplayableManager class, precisely I’ve increased the number of rendering layers in the renderwindow and added additional 2 renderers for 3D model and 2D intersections accordingly.  
As I already wrote, if I could apply the proper transformation matrix to 3D polydata, the problem would be solved then.

---

<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:** [September 7, 2018, 5:09pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/7 "2018-09-07T17:09:31Z")

</div>

You already achieve this visualization in 3D views. You can disable camera rotation by mouse (see Slicer script repository for details). You can also set up slice view to be parallel to the camera image plane (in Reformat module).

In 2D views you can see intersection or (optionally distance-encoded) projection of models.

---

<div class="post-metadata">

**Author:** ![Feodor](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@Feodor](https://discourse.slicer.org/u/Feodor)\
**Post date:** [September 7, 2018, 5:18pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/8 "2018-09-07T17:18:41Z")

</div>

I’m wondering if there is no suitable transformation for the 3d model to be shown properly scaled, considering the fact that this model is already shown as 3D polydata in 2D slice view.

> [@lassoan](#):
>
> or (optionally distance-encoded) projection of models.

Could you please clarify on that?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 7, 2018, 5:25pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/9 "2018-09-07T17:25:30Z")

</div>

I agree with Andras, you can achieve the same thing you want by actually not modifying any classes.

However I think in your case it’s just a matter of removing pipeline-\>Cutter and everything after this filter from the pipeline to prevent creating the slice intersection and showing the model as is. The slice intersection is already in the proper position so you just need to use what is being done there.

---

<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:** [September 8, 2018, 4:20am UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/10 "2018-09-08T04:20:18Z")

</div>

> [@Feodor](#):
>
> wondering if there is no suitable transformation for the 3d model

There certainly is. However, even if the actor appears correctly, by placing 3D content into slice views you violate basic assumption of Slicer core and extension developers. It is difficult to assess what problems it may cause, but probably markup fiducials and other content would be occluded.

---

<div class="post-metadata">

**Author:** ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)\
**Post date:** [May 29, 2024, 9:47am UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/11 "2024-05-29T09:47:48Z")

</div>

Hello,

I would like to discuss this topic again.

Is there an existing implementation where a model appears three-dimensional (3D) in a 2D slice?

 ![2D view](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/3/d3e5cf4dd3414a1494b148d4508d0074411d31b7.png)

The lighting direction and such are not very important as long as it looks three-dimensional.

Thank you.

---

<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:** [May 29, 2024, 1:51pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/12 "2024-05-29T13:51:30Z")

</div>

You can use 3D views if you want to display 3D content over slice images. Click the eye icon in the slice view controller to show the slice image in 3D.

---

<div class="post-metadata">

**Author:** ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)\
**Post date:** [May 29, 2024, 2:16pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/13 "2024-05-29T14:16:41Z")

</div>

Hello Iassoan,

Thank you very much for your response.

As you mentioned, we have confirmed that the feature is available in the 3D view. Thank you for that.

However, our ultimate goal is to create a panoramic view as shown below.

 ![IMG_7830](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/a/8a165472e30ec6d80963b81e6a8ebaf731dd1c25.jpeg)

Is there a way to implement this feature in the 2D Slice?

---

<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:** [May 29, 2024, 2:28pm UTC](https://discourse.slicer.org/t/visualizing-3d-polydata-of-the-model-in-2d-slice-view/4010/14 "2024-05-29T14:28:22Z")

</div>

Yes, of course. Slicer can already compute the panoramic view and display it intermixed with the 3D implants. If you want to show the implants as a 3D rendering overlaid on the panoramic image then you can use a 3D view. If you want to show the implants as intersection lines then probably a slice view is easier.

Note that @cpinter has been working on very similar features for a long time. It may make sense to contact him instead of redeveloping everything from scratch.
