alecjacobson / gptoolbox

Matlab toolbox for Geometry Processing.
MIT License
628 stars 166 forks source link

edge_cylinders: something wrong while running readNODE #89

Closed Frank-Dz closed 4 years ago

Frank-Dz commented 4 years ago

Thanks to your help, my last problem solved > https://github.com/alecjacobson/gptoolbox/issues/88 And now I successfully installed triangle.exe and it did work. Yet, when I went next step, I met this problem:

ERROR: readNODE (line 23) header = fscanf(node_file_handle,'%d %d %d %d',4);

ERROR: triangle (line 231) [TV,I] = readNODE([prefix '.1.node']);

ERROR: fill_holes (line 28) [EVV,EF] = triangle(EV*A,E,[],'Quiet');

ERROR: edge_cylinders (line 220) CF = [CF;fill_holes(CV,CF)];

Again my obj file is as follows:

v 0 0.850651 0.525731
v 0 0.680521 0.420585v 0 1.02078 0.630877
l 1 2
v 0 0.850651 -0.525731
v 0 0.680521 -0.420585v 0 1.02078 -0.630877
l 3 4
v 0 -0.850651 0.525731
v 0 -0.680521 0.420585v 0 -1.02078 0.630877
l 5 6
v 0 -0.850651 -0.525731
v 0 -0.680521 -0.420585v 0 -1.02078 -0.630877
l 7 8
v 0.850651 0.525731 0
v 0.680521 0.420585 0v 1.02078 0.630877 0
l 9 10
v 0.850651 -0.525731 0
v 0.680521 -0.420585 0v 1.02078 -0.630877 0
l 11 12
v -0.850651 0.525731 0
v -0.680521 0.420585 0v -1.02078 0.630877 0
l 13 14
v -0.850651 -0.525731 0
v -0.680521 -0.420585 0v -1.02078 -0.630877 0
l 15 16
v 0.525731 0 0.850651
v 0.420585 0 0.680521v 0.630877 0 1.02078
l 17 18
v -0.525731 0 0.850651
v -0.420585 0 0.680521v -0.630877 0 1.02078
l 19 20
v 0.525731 0 -0.850651
v 0.420585 0 -0.680521v 0.630877 0 -1.02078
l 21 22
v -0.525731 0 -0.850651
v -0.420585 0 -0.680521v -0.630877 0 -1.02078
l 23 24

Is it due to the wrong .OBJ format? Or is there a demo to demonstrate how to use this 'edge_cylinders' function?

Best, Frank

Frank-Dz commented 4 years ago

The input obj file: snapshot00

bbrrck commented 4 years ago

I think your .obj file is fine. There is some problem with reading the .node file output by Triangle. Try removing the 'Quiet' flag when Triangle is called (line 28 of fill_holes.m according to your log) to see if the generated mesh is not empty. If the mesh is fine, the problem might be that the .node file is written into a wrong location or not at all.

Frank-Dz commented 4 years ago

I think your .obj file is fine. There is some problem with reading the .node file output by Triangle. Try removing the 'Quiet' flag when Triangle is called (line 28 of fill_holes.m according to your log) to see if the generated mesh is not empty. If the mesh is fine, the problem might be that the .node file is written into a wrong location or not at all.

Hi~ Thanks for you kind guidance. Yep. I did try to locate the file: image but image

Frank-Dz commented 4 years ago

image Tried. It doesn't work.

Frank-Dz commented 4 years ago

I think I figure it out: image This is due to that there is a '.1.' added into the path?

image However, When I remove the '.1.' for '.ele' files The code tried to find:

C:\Users\Frank\AppData\Local\Temp\tp7d749955_bae1_414d_8ac2_f3691bfee79b.ele

yet there is no this file: image

bbrrck commented 4 years ago

My bad, the output is disabled by default, you have to do [EVV,EF] = triangle(EV*A,E,[],'Quiet',0);

Are you using readOBJ.m from this repo? That one is not reading the edges, so you might be passing empty input to edge_cylinders.m.

Frank-Dz commented 4 years ago

My bad, the output is disabled by default, you have to do [EVV,EF] = triangle(EV*A,E,[],'Quiet',0);

Are you using readOBJ.m from this repo? That one is not reading the edges, so you might be passing empty input to edge_cylinders.m.

I learnt that readOBJ is not able to handle edges, Thus I write a function which can process the situation. image

Plus, image with '0' added, it still doesn't work. : (

bbrrck commented 4 years ago

hm that's weird, maybe try false instead of 0?

Frank-Dz commented 4 years ago

hm that's weird, maybe try false instead of 0?

Still doesn't make it. Is there an alternative for this process (edge2cylinder) ?

image

Or am I missing some external packages?

bbrrck commented 4 years ago

What's the error?

bbrrck commented 4 years ago

Also, have you tried a minimal example? Something like this:

PV = [1 0 0; 0 1 0];
PE = [1 2];
[CV,CF,CJ,CI] = edge_cylinders(PV,PE);
Frank-Dz commented 4 years ago

What's the error?

Still, The code is trying to find C:\Users\Frank\AppData\Local\Temp\tpae6bc758_90a8_44f8_984d_85befae04e08.ele

but This .ele file doesn't exist.

Frank-Dz commented 4 years ago

Tried:

 PV = [1 0 0; 0 1 0];
PE = [1 2];
[CV,CF,CJ,CI] = edge_cylinders(PV,PE);

Same error: The code is trying to find C:\Users\Frank\AppData\Local\Temp\tp873851b3_88af_4f0d_b169_f31df467d16a.ele but this .ele file doesn't exist.

I just do not have .ele files on my windows PC

And I currently run matlab as a administrator.

bbrrck commented 4 years ago

In that case it seems like the mesh given by Triangle is empty.

What is the error when you set the 'Quiet' option to false? If that still doesn't work (which is weird), you can bypass it by setting quiet = false; directly in triangle.m.

Frank-Dz commented 4 years ago

In that case it seems like the mesh given by Triangle is empty.

What is the error when you set the 'Quiet' option to false? If that still doesn't work (which is weird), you can bypass it by setting quiet = false; directly in triangle.m.

I tried set quiet to be false, and just couldn't generate .ele files : C:\Users\Frank\AppData\Local\Temp\tp47b8602f_4746_4ff7_9a01_9ed41bcc41be.ele

The error is that couldn't open this file: image

bbrrck commented 4 years ago

Can you post the output given by Triangle when you set quiet = false? It should be something like this:

Opening /private/tmp/tp2326acc6_0596_41bc_806d_f13c825fb369.poly.
Opening /private/tmp/tp2326acc6_0596_41bc_806d_f13c825fb369.node.
Constructing Delaunay triangulation by divide-and-conquer method.
Delaunay milliseconds:  0
Recovering segments in Delaunay triangulation.
Segment milliseconds:  0
Removing unwanted triangles.
Hole milliseconds:  0

Writing /private/tmp/tp2326acc6_0596_41bc_806d_f13c825fb369.1.node.
Writing /private/tmp/tp2326acc6_0596_41bc_806d_f13c825fb369.1.ele.
Writing /private/tmp/tp2326acc6_0596_41bc_806d_f13c825fb369.1.poly.

Output milliseconds:  0
Total running milliseconds:  1

Statistics:

Input vertices: 4
Input segments: 4
Input holes: 0

Mesh vertices: 4
Mesh triangles: 2
Mesh edges: 5
Mesh exterior boundary edges: 4
Mesh interior boundary edges: 0
Mesh subsegments (constrained edges): 4
Frank-Dz commented 4 years ago

Can you post the output given by Triangle when you set quiet = false? It should be something like this:

Opening /private/tmp/tp2326acc6_0596_41bc_806d_f13c825fb369.poly.
Opening /private/tmp/tp2326acc6_0596_41bc_806d_f13c825fb369.node.
Constructing Delaunay triangulation by divide-and-conquer method.
Delaunay milliseconds:  0
Recovering segments in Delaunay triangulation.
Segment milliseconds:  0
Removing unwanted triangles.
Hole milliseconds:  0

Writing /private/tmp/tp2326acc6_0596_41bc_806d_f13c825fb369.1.node.
Writing /private/tmp/tp2326acc6_0596_41bc_806d_f13c825fb369.1.ele.
Writing /private/tmp/tp2326acc6_0596_41bc_806d_f13c825fb369.1.poly.

Output milliseconds:  0
Total running milliseconds:  1

Statistics:

Input vertices: 4
Input segments: 4
Input holes: 0

Mesh vertices: 4
Mesh triangles: 2
Mesh edges: 5
Mesh exterior boundary edges: 4
Mesh interior boundary edges: 0
Mesh subsegments (constrained edges): 4

I just copy the command generated by MATLAB: image

which is :

C:/local/Triangle/triangle.exe -p  C:\Users\Frank\AppData\Local\Temp\tp99086336_d1b8_4621_ad67_f50989cfd147

And I run it in Cygwin64: image

bbrrck commented 4 years ago

I don't understand, why do you run it from command line?

The output I'm looking for is stored in the result variable in the screenshot you sent.

Frank-Dz commented 4 years ago

I don't understand, why do you run it from command line?

The output I'm looking for is stored in the result variable in the screenshot you sent.

Actually, I am a little confused. Should I just run

[EVV,EF] = triangle(EV*A,E,[],'Quiet',false);
bbrrck commented 4 years ago

Yes. If you set the 'Quiet' flag to false, you'll get a full Triangle output directly in Matlab. Since it didn't work for you for some reason, you can either modify the flag manually in the triangle.m file, or just do disp(result) after Triangle is called, i.e. after the line [status, result] = system( command ); in triangle.m.

Frank-Dz commented 4 years ago

Yes. If you set the 'Quiet' flag to false, you'll get a full Triangle output directly in Matlab. Since it didn't work for you for some reason, you can either modify the flag manually in the triangle.m file, or just do disp(result) after Triangle is called, i.e. after the line [status, result] = system( command ); in triangle.m.

I am not sure that am I right ? image

image

That means the output ‘result’ is null. I don't why I did not generate a .ele file? image

bbrrck commented 4 years ago

That is right, the output is empty, which means the call to Triangle is not executed properly. I suggest you have a look at the instructions for Triangle to first make it work outside of Matlab on a simple example, such as a .node file with three input points.

Frank-Dz commented 4 years ago

ok I will have a try. Plus, have you tried running the prog on you PC? Is the result of the prog ok on your machine? Thanks again for you kind help!

Desideriuswang commented 4 years ago

thank you

------------------ 原始邮件 ------------------ 发件人: "Zhiyang-Dou"<notifications@github.com>; 发送时间: 2020年1月13日(星期一) 下午4:14 收件人: "alecjacobson/gptoolbox"<gptoolbox@noreply.github.com>; 抄送: "Subscribed"<subscribed@noreply.github.com>; 主题: Re: [alecjacobson/gptoolbox] edge_cylinders: something wrong while running readNODE (#89)

Closed #89.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.