# Load mesh with wavefront (obj) format

**URL:** <https://discourse.slicer.org/t/load-mesh-with-wavefront-obj-format/15191>\
**Category:** Support\
**Tags:** 3d-model, file-import\
**Created:** [December 22, 2020, 3:00pm UTC](https://discourse.slicer.org/t/load-mesh-with-wavefront-obj-format/15191 "2020-12-22T15:00:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yixun\_Liu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yixun_liu/32/9310_2.png) [@Yixun\_Liu](https://discourse.slicer.org/u/Yixun_Liu)\
**Post date:** [December 22, 2020, 3:00pm UTC](https://discourse.slicer.org/t/load-mesh-with-wavefront-obj-format/15191/1 "2020-12-22T15:00:04Z")

</div>

Hi,  
I use 3DSlicer to load a mesh, which was created from a volume with suffix .mhd.  
The volume is loaded using ITK and the mesh is generated using vtk marchingcube by an in-house tool. The mesh is saved into wavefront format with suffix obj.

I have several questions:

1. Is the mesh created in the LPS space no matter what AnatomicalOrientation is in the mhd file?
2. As I load the mesh into 3DSlicer, is it rendered in the RAS space?

Thank a lot!

Yixun

---

<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:** [December 22, 2020, 8:36pm UTC](https://discourse.slicer.org/t/load-mesh-with-wavefront-obj-format/15191/2 "2020-12-22T20:36:48Z")

</div>

In recent Slicer versions, surface meshes are assumed to be in LPS coordinate system, unless you specify RAS coordinate system in the file header. See more information here: [https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide/Slicer#Slicer\_5.0:\_Models\_are\_saved\_in\_LPS\_coordinate\_system\_by\_default](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide/Slicer#Slicer_5.0:_Models_are_saved_in_LPS_coordinate_system_by_default)

---

<div class="post-metadata">

**Author:** ![Yixun\_Liu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yixun_liu/32/9310_2.png) [@Yixun\_Liu](https://discourse.slicer.org/u/Yixun_Liu)\
**Post date:** [December 23, 2020, 1:28am UTC](https://discourse.slicer.org/t/load-mesh-with-wavefront-obj-format/15191/3 "2020-12-23T01:28:34Z")

</div>

Many thanks for your promptly reply.

For the mesh creation, I use ITK to load a .mhd file and then convert it to vtkImage and then use vtkMarchingcube to generate a mesh. Is the mesh created in the volume space determined by the offset and the transformMatrix (offset and transformMatrix are tags in .mhd file ) no matter what the AnatomicalOrientation is?

---

<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:** [December 23, 2020, 2:12am UTC](https://discourse.slicer.org/t/load-mesh-with-wavefront-obj-format/15191/4 "2020-12-23T02:12:37Z")

</div>

ITK follows current guidance on interpretation of mha files in that it ignores the AnatomicalOrientation field and assumes the image is defined in LPS coordinate system. Since current Slicer versions expect meshes to be in LPS coordinate system, there should be no need for conversion.

Note that you don’t need to use marching cubes in an external software. You can load the mha file directly into Slicer as a segmentation node (select “Segmentation” in Add data dialog in the description column). Mesh representation of the segmentation will be created automatically when needed, using methods that are better than simple marching cubes (flying edges filter followed by Taubin smoothing) - when you right-click on the segmentation and choose export to model, or click show 3D in Segment Editor.

What is the end goal of your project? What are the steps in your workflow that have not been completed yet?

---

<div class="post-metadata">

**Author:** ![Yixun\_Liu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yixun_liu/32/9310_2.png) [@Yixun\_Liu](https://discourse.slicer.org/u/Yixun_Liu)\
**Post date:** [December 24, 2020, 2:52am UTC](https://discourse.slicer.org/t/load-mesh-with-wavefront-obj-format/15191/5 "2020-12-24T02:52:17Z")

</div>

Thanks Andras.  
We are developing a specific surgery planning system with segmentation and mesh generation. Slicer has powerful edit functionality and we often use it to edit our segmentation results and visualize the mesh.  
But sometimes the mesh and the segmentation volume do not align well in the 3D rendering window. Now I understand it is because the mesh might not be created in the LPS space.

Thanks a lot for your help!

---

<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:** [December 24, 2020, 3:58am UTC](https://discourse.slicer.org/t/load-mesh-with-wavefront-obj-format/15191/6 "2020-12-24T03:58:59Z")

</div>

Thanks for the information. In case you don’t know, Slicer is used as a basis of several surgical planning and real-time guidance systems (including commercial ones, with regulatory approval), with completely custom GUI layer (you would not recognize that the engine of the application is Slicer). Check out these links for some more details:

- [www.slicerigt.org](http://www.slicerigt.org)
- [https://slicer.readthedocs.io/en/latest/user\_guide/about.html#commercial-use](https://slicer.readthedocs.io/en/latest/user_guide/about.html#commercial-use)
- [https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/)

---

<div class="post-metadata">

**Author:** ![Yixun\_Liu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yixun_liu/32/9310_2.png) [@Yixun\_Liu](https://discourse.slicer.org/u/Yixun_Liu)\
**Post date:** [December 25, 2020, 1:13am UTC](https://discourse.slicer.org/t/load-mesh-with-wavefront-obj-format/15191/7 "2020-12-25T01:13:29Z")

</div>

Yes, I know and also use them too.  
Thank you so much for your help!
