VTK is ignoring the “o” specifier in Wavefront OBJ files.
Blender is one of the few programs that handles this correctly. To see the issue, create 2 cylinders in Blender and export as OBJ, then read into VTK. You only get one object, not two.
The named object capability is vital for many things. In cell biology we need the ability to distinguish organelles from the plasma membrane.
Is there a workaround for this, or could we get VTK to return an array of objects or something?
I’ve confirmed this in detail. Neither the OBJReader nor OBJImporter work correctly. The importer documentation explicitly states it doesn’t support the scene heirarchy API, even though it advertises that it does.
The named object capability is one of the big reasons people use OBJ instead of STL or other formats. In VTK you can SetObjectName(), which should save into the OBJ as an “o” specifier. On the way back in, each “o” needs up become a separate mesh.
VTK should be returning an array of meshes on import, not just one gigantic mesh. In HDF5 they handle this with registration metadata, but mere mortals have to use OBJ if a non-proprietary format is needed.
Yes. I create each object in the usual way in Blender, using Add => Mesh => x, where x could be a sphere or cube or any shape. In the OBJ file there is a line saying “o object_name” ahead of every set of vertices. In the attached file there are two objects, a cylinder and a sphere. The OBJ was created straight from Blender with File => Export => Wavefront OBJ.
Well… I tried to upload the file, it says “new users can not upload attachments”. Let me see if I can copy in the first few lines of the file. What comes after the “o” is the object name, in this case it’s just “Cylinder” because I didn’t name it anything special. The next one would be Cylinder_002 and so on.
Blender v2.93.1 OBJ File: ‘’
mtllib blender_output.mtl o Cylinder
v -2.228397 0.264313 1.566652
v -2.228397 2.264313 1.566652
v -2.033306 0.264313 1.585867
The primary need is to keep the objects separable. In Blender you can look at the object list on the top right, there you can click on any object and highlight its components. It doesn’t matter if an object is inside another object, that’s a different concept. There’s also a “g” option for group. Yes you’re right it’s a primitive form of scene definition. As far as I know there is no open/public standard that lets biologists build cells. It would be like a “sub-assembly” concept in manufacturing. However the basic need is just to keep the objects separated, so we know this membrane belongs to the nucleus and that one belongs to an organelle. When I click on the organelle in Blender, I don’t want to select the whole cell!
Thank you! Here are three files, in increasing order of complexity. The first one blender_output.obj is simple, it just has two objects, a sphere and a cylinder. It was created by Blender, using File => Export => Wavefront OBJ. The second one blender_output_test1.obj has 5 objects, all cylinders, they overlap spatially (this is like reconstructing a branch of a neuron from a skeleton tracing). The third one is the most complicated, it has objects within objects (geometrically), it would be much like organelles within a cell (in this case it’s a portion of a neural network). In this last one, to see the internal objects in Blender, you have to change the outer cube to a wire frame display. Also attaching an mtl file, which you can copy and rename as needed for Blender.
Wait… what are we looking at here? To get the list on the left, you’re enumerating actors? I have to work backwards to the underlying data points? That would explain some things, i’ll go try it. (I was originally trying to get the intersections between the cylinders).
To get the list on the left, you’re enumerating actors?
Not exactly, we are using this API: vtkImporter::GetSceneHierarchy and vtkImporter::GetImportedActors
get the intersections between the cylinders
Thats not really related, to get the intersection you need some kind of boolean computation, which VTK is not really tooled for, but Vespa (https://gitlab.kitware.com/vtk/meshing/vespa) can I think.