-1

I'm trying to Import OBJ format 3D mesh file via VCG Library with this code below

vcg::tri::io::Importer<MyMesh>::Open(vcgMesh, path)

Almost every 3D mesh formats that /wrap/io_trimesh/import.h header supports are working fine. (STL, PLY, even OBJ!)
but only some specific OBJ file causes an error and crashes the application completely.
For example, OBJ file that I've got from this link https://free3d.com/3d-model/wwi-plane-pfalz-diii-a-90772.html

Here is the error msg that I've got

/vcg/simplex/edge/component.h:46: typename T::VertexType*& vcg::edge::EmptyCore<T>::V(int) [with T = MyUsedTypes; typename T::VertexType = MyVertex]: Assertion `0' failed [1]    24708 abort (core dumped)

The thing is I cannot even try and catch the error. and I couldn't find any solution to prevent my application to be crashed from it.
I've tried to open the file in blender and MeshLab. Those applications import the OBJ file without any problem.
Here are kind of related issues but none of the solutions work out on this case.
Failed to to simplify 3D models with vcglib, Assertion `0' failed
Assertion Failure when using vcglib examples

Is there any way to solve this problem? Even if it's a problem with vcglib itself and it's hard to fix it, it would be great if I could catch the error and prevent my application to be crashed. Please help! Thank you in advance.

genpfault
  • 51,148
  • 11
  • 85
  • 139

1 Answers1

0

I've tried to open the file in blender and MeshLab. Those applications import the OBJ file without any problem.

Really? Your obj file is not valid, it is impossible that meshlab or blender will process a .obj file with lines as:

vt 0.349751 0.599421
vt 0.351053 0.607569
vt 0.369663 0.673393
vt nan nan
vt nan nan
vt nan nan

Also, some textures are with absolute paths like

map_Kd /C:/Documents and Settings/Jean-Marie/Mes documents/....
Rockcat
  • 3,002
  • 2
  • 14
  • 28
  • I don't know if the inner file structure is correct or not, but blender and meshlab can open without a problem even without texture or material files. I am wondering if you tested with the correct model that I linked above. please check out this screenshot [Screenshot](https://drive.google.com/file/d/1Ie4SkoKCjuVvZ-R-LkK4ruMtoAyGemLs/view?usp=sharing) – Steve. Kim Oct 30 '19 at 00:04
  • You said "Those applications import the OBJ file without any problem", but I tested on meshlab 2016.12 and got 12 errors complaining about texture filenames before of a meshlab crash with "Segmentation fault ". In the console I have even more errors of type "Warning there is a degenerate poligon of 7 verteces that was triangulated into 0 triangles" – Rockcat Oct 30 '19 at 08:24
  • Have you checked the screenshot that I have attached? I'm not sure if we are talking about the same model. please check the name of the model you downloaded. mine is 'pfalzD3a.obj' and it definitely can be opened at blender and meshlab as I attached above – Steve. Kim Nov 02 '19 at 11:15
  • Yes, it is. And it has several issues that may produce errors on some loaders. The mesh has degenerate polygons that cannot be triangulated, and has texture coordinates with Nan (not a number) values. Some readers may detect and ignore these problems, but others (as VCG) choose to be strict and not ignore those problems. If blender or old version of meshlab can load the model, just save it in a new file and try to open that copy with modern VCG – Rockcat Nov 02 '19 at 23:15
  • Oh, I got it now, thank you so much. the thing is I'm building some application with VCG, so when there is an exception like this, the app should catch the exception and shouldn't be turned off. I guess this implementation would be a little bit hard. Do you have any idea how to catch this exception and prevent app crash? – Steve. Kim Nov 03 '19 at 11:39
  • You can use try {} catch only if the error is produced by an exception. In this case, it looks like it is an assert meaning than you can't catch it. Probably the problem appears only if you are compiling in Debug mode, so VCG enable the assertions. Can you try to compile VCG in release mode? – Rockcat Nov 03 '19 at 12:41