How to export segments as one object with colors

Operating system: Windows 10
Slicer version: 5.2.2
Expected behavior: Creating volumetric mesh
Actual behavior: exporting few segment as one object with their colors

Hello everyone,

I want to import part of brain into COMSOL. There are four segments and I have tried it by exporting them into a STL file. But due to some defects in the interface of segments it seems impossible. So now, I want to have them all in one object in the STL file plus their colors. In fact, when I merge them, there wouldn’t be any fault with geometry. On the other hand, only by using their colors I can define their domains in COMSOL.

With this description, Do you have any suggestion?

Best wishes,

STL format is very limited. You might be able to use vtk format, and use the Segment Mesher extension to create a mesh more suited to simulation.

Thanks for your response.
I have test it. COMSOL doesn’t support vtk format. Then I used meshio but it also doesn’t support msh or mesh files.

There is probably a path to convert using some off the shelf tools, but if you know what you need for COMSOL it’s probably easy to write a python script to generate the right format. I don’t use COMSOL, but if you are a customer of theirs they should be able to help you with this.

Again thank you for your attention.

In fact, I have talked to COMSOL supporter but it is a problem from the input data. It easy can import a wide range of data such as STL, STEP, OBJ, and so on. But as you can see in the following picture there are some self intersecting faces (red points) around the model.

I am not sure but maybe Volume clipping has caused this problem in the final step.

So again want you or @lassoan to help me to get an output (preferable OBJ or STL) which can build these segments as one object while containing different colors as the representative of segments. Even a clue can be so beneficial for me.

I really appreciate your consideration.

Best wishes,

The SegmentMesher has many options so you should really try that. GitHub - lassoan/SlicerSegmentMesher: Create volumetric mesh from segmentation using Cleaver2 or TetGen

You may also want to try using the cleaver or tetgen tools directly.