jonhrafe / MCDC_Simulator_public

The Monte Carlo Diffusion and Collision simulator (MC/DC), is a C++ open-source Diffusion-Weighted Magnetic Resonance Imaging (DW-MRI) Monte Carlo Simulator.
https://jonhrafe.github.io/MCDC_Simulator_public/
GNU Lesser General Public License v2.1
19 stars 12 forks source link

Issue with simple PLY mesh #6

Closed fragrussu closed 3 years ago

fragrussu commented 3 years ago

Hello Jon,

I am trying to simulate diffusion within a very simple substrate - a cube with side of 20um. I using this simple mesh:

ply format ascii 1.0 comment created by Francesco Grussu element vertex 8 property float x property float y property float z element face 6 property list uchar uint vertex_indices end_header 0e+00 0e+00 0e+00 0e+00 0e+00 20e-06 0e+00 20e-06 20e-06 0e+00 20e-06 0e+00 20e-06 0e+00 0e+00 20e-06 0e+00 20e-06 20e-06 20e-06 20e-06 20e-06 20e-06 0e+00 4 0 1 2 3 4 7 6 5 4 4 0 4 5 1 4 1 5 6 2 4 2 6 7 3 4 3 7 4 0

and I get the following error:

[ERROR] PLY mesh should be completely triangulated. PLY format error: MC-CD_Simulator: simerrno.cpp:81: static bool SimErrno::checkSimulationParameters(Parameters&): Assertion `checkPLYFiles(params)' failed.

I thought that the issue was that faces as defined in the PLY file were squares, and not triangles. I have tried to split them into two triangles each and I still get the error. The second PLY file I tried is:

ply format ascii 1.0 comment created by FG element vertex 8 property float x property float y property float z element face 12 property list uchar uint vertex_indices end_header 0e+00 0e+00 0e+00 0e+00 0e+00 20e-06 0e+00 20e-06 20e-06 0e+00 20e-06 0e+00 20e-06 0e+00 0e+00 20e-06 0e+00 20e-06 20e-06 20e-06 20e-06 20e-06 20e-06 0e+00 4 0 1 2 4 0 2 3 4 7 6 5 4 7 5 4 4 0 4 5 4 0 5 1 4 1 5 6 4 1 6 2 4 2 6 7 4 2 7 3 4 3 7 4 4 3 4 0

Any clue why that is happening? Any suggestion on how I could fix this?

Thank you very much in advance.

Regards, Francesco Grussu

jonhrafe commented 3 years ago

Hey Francesco.

Yes! If I'm correct it's because the elements' list of edges should start with a "3", since triangulated meshes should have 3 vertices per triangle. See below:

ply format ascii 1.0 comment Created by Blender 2.83.0 - www.blender.org, source file: '' element vertex 8 property float x property float y property float z element face 12 property list uchar uint vertex_indices end_header 0.000000 0.000000 0.000000 0.000000 0.000000 0.000020 0.000000 0.000020 0.000020 0.000000 0.000020 0.000000 0.000020 0.000020 0.000000 0.000020 0.000020 0.000020 0.000020 0.000000 0.000020 0.000020 0.000000 0.000000 3 0 1 2 3 0 2 3 3 4 5 6 3 4 6 7 3 0 7 6 3 0 6 1 3 1 6 5 3 1 5 2 3 2 5 4 3 2 4 3 3 3 4 7 3 3 7 0

Hope this helps.

Best. J.R.

fragrussu commented 3 years ago

Hi Jon,

Thanks a lot for the suggestion - it now works perfectly! As you can see, I am still new to the PLY format :)

Thanks again for the prompt help. All the best, Francesco