songrun / SeamAwareDecimater

Mesh simplification with UV's boundary preserved
https://cragl.cs.gmu.edu/seamless/
MIT License
500 stars 61 forks source link

Fails on every file I try #6

Open John-Nagle opened 6 years ago

John-Nagle commented 6 years ago

I exported the default cube from Blender to .obj. Result:

 decimater testcube.obj  percent-vertices 90
Warning: readOBJ() ignored non-comment line 4:
  o Cube
Loaded a mesh with 8 vertices and 6 faces: testcube.obj
90% of 8 input vertices is 7 output vertices.
decimater: /home/john/projects/sl/SeamAwareDecimater/decimater.cpp:85: bool {anonymous}::decimate_down_to(const Eigen::PlainObjectBase<Derived>&, const Eigen::PlainObjectBase<DerivedTC>&, const Eigen::PlainObjectBase<DerivedCN>&, const Eigen::PlainObjectBase<DerivedTC>&, int, Eigen::MatrixXd&, Eigen::MatrixXi&, Eigen::MatrixXd&, Eigen::MatrixXi&, bool) [with DerivedV = Eigen::Matrix<double, -1, -1>; DerivedF = Eigen::Matrix<int, -1, -1>; DerivedT = Eigen::Matrix<double, -1, -1>; Eigen::MatrixXd = Eigen::Matrix<double, -1, -1>; Eigen::MatrixXi = Eigen::Matrix<int, -1, -1>]: Assertion `F.cols() == 3' failed.
Aborted (core dumped)

OK, so maybe reducing a cube while preserving seams is geometrically impossible.

The default cylinder from Blender:

decimater testcylinder.obj  percent-vertices 90
Warning: readOBJ() ignored non-comment line 4:
  o Cylinder
Failed to cast F to matrix: min (4) != max (32)
ERROR: Could not read OBJ: testcylinder.obj

I get that "Failed to cast F to matrix" error from everything I've tried - simple files from Blender, files from 3D sites.

But the "animal.obj" file provided with the source code poly reduces just fine. So the program passes its own test case.

John-Nagle commented 6 years ago

Test objects mentioned above. failobjs.zip

songrun commented 6 years ago

Hi John,

Can you try to triangulate the obj file first? My OBJ importer only takes clean triangle mesh.


Best, Songrun Liu, https://songrun.github.io/ PhD student & Research Assistant Volgenau School of Engineering George Mason University

On May 5, 2018, at 12:03 AM, John Nagle notifications@github.com wrote:

Test objects mentioned above. failobjs.zip https://github.com/songrun/SeamAwareDecimater/files/1976316/failobjs.zip — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/songrun/SeamAwareDecimater/issues/6#issuecomment-386777172, or mute the thread https://github.com/notifications/unsubscribe-auth/AAq5AjL6dpdVmZNd_eW-n97VVtPa0o4hks5tvSSHgaJpZM4TzLpL.

John-Nagle commented 6 years ago

Triangulated the cylinder. Result:

 decimater testcylindertris.obj  percent-vertices 80 testcylindertris50.obj
Warning: readOBJ() ignored non-comment line 4:
  o Cylinder
Loaded a mesh with 64 vertices and 124 faces: testcylindertris.obj
80% of 64 input vertices is 51 output vertices.
decimater: /home/john/projects/sl/SeamAwareDecimater/decimater.cpp:87: bool {anonymous}::decimate_down_to(const Eigen::PlainObjectBase<Derived>&, const Eigen::PlainObjectBase<DerivedTC>&, const Eigen::PlainObjectBase<DerivedCN>&, const Eigen::PlainObjectBase<DerivedTC>&, int, Eigen::MatrixXd&, Eigen::MatrixXi&, Eigen::MatrixXd&, Eigen::MatrixXi&, bool) [with DerivedV = Eigen::Matrix<double, -1, -1>; DerivedF = Eigen::Matrix<int, -1, -1>; DerivedT = Eigen::Matrix<double, -1, -1>; Eigen::MatrixXd = Eigen::Matrix<double, -1, -1>; Eigen::MatrixXi = Eigen::Matrix<int, -1, -1>]: Assertion `TC.cols() == 2' failed.
Aborted (core dumped)
John-Nagle commented 6 years ago

failobjs2.zip Test files for above. The triangulated cylinder is the Blender default cylinder triangulated with the default Blender triangulation. The attached image shows a valid triangulation.

Similar failure on a chair model. I can't get this program to work on anything but the provided "animal.obj".

songrun commented 6 years ago

Your cylinder model even doesn’t have a UV mapping.


Best, Songrun Liu, https://songrun.github.io/ PhD student & Research Assistant Volgenau School of Engineering George Mason University

On May 5, 2018, at 2:33 PM, John Nagle notifications@github.com wrote:

failobjs2.zip https://github.com/songrun/SeamAwareDecimater/files/1976949/failobjs2.zip Test files for above. The triangulated cylinder is the Blender default cylinder triangulated with the default Blender triangulation. The attached image shows a valid triangulation.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/songrun/SeamAwareDecimater/issues/6#issuecomment-386825920, or mute the thread https://github.com/notifications/unsubscribe-auth/AAq5Ag3-GW3sA7txBVM99MGgctHhWsPQks5tvfB_gaJpZM4TzLpL.

John-Nagle commented 6 years ago

Thanks.

Next problem:

capsulefail.zip

This is the "minimal textured object file" from http://paulbourke.net/dataformats/obj/minobj.html used as a demo and test case.

The mesh reduction opens up a sizable gap in the mesh between the upper and lower halves of the object. Oops.

TheOriginalBytePlayer commented 3 years ago

I think I may have a solution -- a lot of OBJ files have 3 UVS. which is valid, though they actually seem to only use the first 2 values as the 3rd is always zero. In any case

  1. Goto the ReadOBJ.cpp file, and to insert the line

        Count = 2;

just before Line 131,

       std::vector<Scalar > tex(count);

You need to do this because the decimation function requires the UVs to have exactly 2 columns and OBJ can legally have 3. By Explicitly setting it to 2 you are tossing the third value which appears to always be zero in files I’ve seen, anyway.

Similarly, OBJ files can legally have NO UVs but the library can't handle that, so make sure they have UVs assigned.

John-Nagle commented 3 years ago

Ah. Two years later, but good info.

TheOriginalBytePlayer commented 3 years ago

Yeah, better late than never, I suppose!

From: John Nagle @.> Sent: Friday, July 02, 2021 2:21 PM To: songrun/SeamAwareDecimater @.> Cc: TheOriginalBytePlayer @.>; Comment @.> Subject: Re: [songrun/SeamAwareDecimater] Fails on every file I try (#6)

Ah. Two years later, but good info.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/songrun/SeamAwareDecimater/issues/6#issuecomment-873262363 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJYX4HWPOC25OKSKI6H5PDTVYUTTANCNFSM4E6MXJFQ . https://github.com/notifications/beacon/AEJYX4B3VNZX2VHLC7XBJU3TVYUTTA5CNFSM4E6MXJF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGQGO2GY.gif