converting .vtp to .obj

2,900 views
Skip to first unread message

Greg Hanowski

unread,
Sep 16, 2013, 12:50:38 AM9/16/13
to vmtk-...@googlegroups.com

Hi all,
I have .obj files of arteries and veins that I successfully imported into blender and now I need to create centerlines for them as well. I've learned how to convert the .obj files to .vtp (VTK polydata format) using VTK software. Then I learned how to use VMTK (vascular modeling toolkit) to generate centerlines, which are also in .vtp format. Now the last step - converting them back into something blender can import. I've managed to convert them to .ply but those came in as dots along the centerline, rather than a line segment. VTK has a script called vtkObjExporter but I've been unable to get it to work. Anybody have any other suggestions?
Thank you,
Greg

zhangx29

unread,
Sep 16, 2013, 10:26:46 AM9/16/13
to vmtk-...@googlegroups.com
Hi Greg,

I have recently done so. Here is what I did: 1) convert vtp to more universally accepted stl format using vmtksurfacewriter; 2) import stl into Blender, export as OpenInventor format (*.iv); 3) use MINC tools iv2bicobj to convert from iv to obj.

I realize that not everyone use MINC tools and Blender can export obj format, so you might be able to combine step 2) and 3) just by exporting obj directly in Blender.

hope this help,
Xiaoli

zhangx29

unread,
Sep 16, 2013, 10:33:32 AM9/16/13
to vmtk-...@googlegroups.com
Just read your question again, if you just need Blender to read the centerline file. You may only need the first step and use stl in Blender.


On Monday, September 16, 2013 12:50:38 AM UTC-4, Greg Hanowski wrote:

Greg Hanowski

unread,
Sep 16, 2013, 12:58:42 PM9/16/13
to vmtk-...@googlegroups.com

Xiaoli,

Thanks for the suggestion.  I was able to convert trachea.vtp to trachea.stl using the following command:

vmtksurfacewriter -ifile "C:/Users/Greg/Documents/VMTK/trachea.vtp" -ofile "C:/Users/Greg/Documents/VMTK/trachea.stl"

and it imported into blender ok.

 

Next I used the following command to convert it's centerline:

vmtksurfacewriter -ifile "C:/Users/Greg/Documents/VMTK/trachea_centerline.vtp" -ofile "C:/Users/Greg/Documents/VMTK/trachea_centerline.stl"

 

It created a file but when I imported into blender, nothing showed up.  Maybe .stl files only handle polygons and not line segments?

Any other suggestions?

Greg

--
You received this message because you are subscribed to the Google Groups "vmtk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vmtk-users+...@googlegroups.com.
To post to this group, send email to vmtk-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

zhangx29

unread,
Sep 16, 2013, 4:53:44 PM9/16/13
to vmtk-...@googlegroups.com
Hi Greg,

I tried the conversion on a centerline and it doesn't work. You are right that maybe it is looking for polygon. Maybe someone else in this group could help. Worst case you could export coordinates of the centerline points as text file in vmtk and re-create the centerline from the coordinates?

Arjan Geers

unread,
Sep 16, 2013, 5:57:23 PM9/16/13
to vmtk-...@googlegroups.com
Hi Greg, 

I'm not sure STL can represent lines. Try to export the 'scene' from Paraview as x3d and import it into Blender. This x3d contains besides the centerline also information about Paraview's camera viewpoint and light sources. You should then be able to export the centerline itself as obj.

Hope this helps, 

Arjan

Greg Hanowski

unread,
Sep 16, 2013, 8:38:36 PM9/16/13
to vmtk-...@googlegroups.com

Hello Arjan,

When I open trachea_centerline.vtp in paraview it shows the name in the Pipeline Browser but I don't see anything but an xyz coorsys at bottom left and a bigger unlabeled one in the center.  Rotating or zooming does not bring anything else into view.

 

It shows up fine in vmtk using the following command:

vmtkrenderer --pipe vmtksurfaceviewer -opacity 0.25 -ifile "C:/Users/Greg/Documents/VMTK/trachea.vtp" --pipe vmtkcenterlineviewer -ifile "C:/Users/Greg/Documents/VMTK/trachea_centerline.vtp"

 

Does paraview have trouble with line segments too, or am I missing something obvious?

Greg

Arjan Geers

unread,
Sep 17, 2013, 3:31:57 AM9/17/13
to vmtk-...@googlegroups.com
Hi Greg, 

Try to 'zoom to data' in Paraview (see red circle in attached screenshot). If that doesn't work, feel free to send over the file so I could have a look.

Arjan
paraview_zoom_to_data.png

Greg Hanowski

unread,
Sep 17, 2013, 9:37:48 AM9/17/13
to vmtk-...@googlegroups.com

Arjan,

I also loaded trachea.vtp.  Zoom to data did nothing in either case.  Enclosed are the two files.  Thanks for offering to have a look.

trachea.vtp
trachea_centerline.vtp

Jason Smith [Contractor]

unread,
Sep 17, 2013, 9:50:36 AM9/17/13
to vmtk-...@googlegroups.com
Hi Greg,

Your files open and display for me in Paraview.  Make sure you have the objects set to be visible in your pipeline browser, screenshot attached.

--jason
Inline image 1
greg_paraview.png

Greg Hanowski

unread,
Sep 17, 2013, 10:08:10 AM9/17/13
to vmtk-...@googlegroups.com

Hello Jason,

The area where you show an eye is completely blank for me.  I am using ParaView 4.0.1 32-bit on a windows 8 machine.  I looked around in Settings and View Settings but could not find anything about visibility.  Right-clicking on the object in the Pipeline Browser also did not have any visibility options.

Greg

image002.jpg

Arjan Geers

unread,
Sep 17, 2013, 10:09:17 AM9/17/13
to vmtk-...@googlegroups.com
I can see them in Paraview 4.0.0. After opening the file, click on 'Apply'.
image002.jpg

Greg Hanowski

unread,
Sep 17, 2013, 10:10:57 AM9/17/13
to vmtk-...@googlegroups.com

That did it.  I figured it would be something silly.  Thanks!

image001.jpg

Greg Hanowski

unread,
Sep 17, 2013, 10:34:56 AM9/17/13
to vmtk-...@googlegroups.com

Arjan,

Indeed, that worked.  Thanks so much for your help!  You too Jason.

Greg

 

From: vmtk-...@googlegroups.com [mailto:vmtk-...@googlegroups.com] On Behalf Of Arjan Geers


Sent: Monday, September 16, 2013 3:57 PM
To: vmtk-...@googlegroups.com

zhangx29

unread,
Oct 11, 2013, 10:48:26 PM10/11/13
to vmtk-...@googlegroups.com
Hi Greg,

How would you convert the .obj file to .vtp?

Thanks,
Xiaoli


On Monday, September 16, 2013 12:50:38 AM UTC-4, Greg Hanowski wrote:

Greg Hanowski

unread,
Oct 12, 2013, 6:41:22 AM10/12/13
to vmtk-...@googlegroups.com

Hi Xiaoli,

I modified an existing script to do the following:

 

#include <vtkSmartPointer.h>

#include <vtkPolyDataMapper.h>

#include <vtkActor.h>

#include <vtkRenderWindow.h>

#include <vtkRenderer.h>

#include <vtkRenderWindowInteractor.h>

#include <vtkOBJReader.h>

#include <vtkUnstructuredGrid.h>

#include <vtkCell.h>

#include <vtkCellArray.h>

#include <vtkIdList.h>

#include <vtkUnsignedCharArray.h>

#include <vtkPointData.h>

#include <string>

#include <vtkXMLPolyDataWriter.h>

 

int main(int argc, char *argv[])

{

  // Parse command line arguments

  if(argc != 2)

    {

    std::cout << "Usage: " << argv[0] << " Filename(.obj)" << std::endl;

    return EXIT_FAILURE;

    }

 

  std::string InputFilename  = argv[1];

 

   char path_buffer[_MAX_PATH];

   char drive[_MAX_DRIVE];

   char dir[_MAX_DIR];

   char fname[_MAX_FNAME];

   char ext[_MAX_EXT];

 

  _splitpath( InputFilename.c_str(), drive, dir, fname, ext );

  _makepath( path_buffer, drive, dir, fname, ".vtp" );

  std::string OutputFilename = path_buffer;

 

  vtkSmartPointer<vtkOBJReader> reader = vtkSmartPointer<vtkOBJReader>::New();

  reader->SetFileName(InputFilename.c_str());

  reader->Update();

 

  // Visualize

  vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();

  mapper->SetInputConnection(reader->GetOutputPort());

 

  vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();

  actor->SetMapper(mapper);

 

  vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();

  vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();

  renderWindow->AddRenderer(renderer);

  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();

  renderWindowInteractor->SetRenderWindow(renderWindow);

 

  renderer->AddActor(actor);

  renderer->SetBackground(.3, .6, .3); // Background color green

 

  renderWindow->Render();

  renderWindowInteractor->Start();

 

  vtkSmartPointer<vtkXMLPolyDataWriter> writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New();

  writer->SetFileName(OutputFilename.c_str());

  writer->SetInputConnection(reader->GetOutputPort());

 

  writer->Write();

 

 

  return EXIT_SUCCESS;

}

 

I compiled it in Microsoft Visual Studio Express 2012 for Windows Desktop.

 

Greg

 

From: vmtk-...@googlegroups.com [mailto:vmtk-...@googlegroups.com] On Behalf Of zhangx29
Sent: Friday, October 11, 2013 8:48 PM
To: vmtk-...@googlegroups.com
Subject: [vmtk-users] Re: converting .vtp to .obj

 

Hi Greg,

--

zhangx29

unread,
Oct 12, 2013, 9:25:02 AM10/12/13
to vmtk-...@googlegroups.com
Hi Greg,

If you don't mind could you test the dataset I attached here to see if the conversion work on this particular file? I got 0 vertex when read the obj file using the Python code. I don't have the C++ compile environment for VTK and I would like to isolate whether the problem is my Python code or the dataset itself.

Thanks in advance,
Xiaoli
obj2vtp_test.obj

Greg Hanowski

unread,
Oct 12, 2013, 12:00:00 PM10/12/13
to vmtk-...@googlegroups.com

Hi Xiaoli,

I opened it in ParaView, hit Apply button, then Zoom to Data.  I could see no geometry.

Next I imported into Blender and also could see nothing.

Next I opened it in 3D Object Converter v5.20 and got the error message "Unrecognized or unsupported file type!  (or no valid object found !)

So evidently, there is something bad about the data.

Greg

 

From: vmtk-...@googlegroups.com [mailto:vmtk-...@googlegroups.com] On Behalf Of zhangx29


Sent: Saturday, October 12, 2013 7:25 AM
To: vmtk-...@googlegroups.com

zhangx29

unread,
Oct 13, 2013, 9:13:45 AM10/13/13
to vmtk-...@googlegroups.com
Hi Greg,

You are right, the problem is indeed my .obj file. It turned out the .obj I got was a non-standard MNI obj file, while usually .obj are referred to Wavefront obj format.

Thanks for your help,
Xiaoli
Reply all
Reply to author
Forward
0 new messages