mkazhdan / PoissonRecon

Poisson Surface Reconstruction
MIT License
1.51k stars 422 forks source link

the program crushed with empty file write error message. #297

Open YQGong opened 3 weeks ago

YQGong commented 3 weeks ago

The program runs perfectly until I switch to a new computer with a 32-threads cpu(i9-13900HX) and windows10(version 19044.1288).

The command and the verbose error message looks like:

PoissonRecon.exe --in pcd_out.ply --envelope envelope_mesh.ply --out mesh_poisson.ply --verbose --threads 1
*************************************************************
*************************************************************
** Running Screened Poisson Reconstruction (Version 16.01) **
*************************************************************
*************************************************************
        --in pcd_out.ply
        --out mesh_poisson.ply
        --envelope envelope_mesh.ply
        --verbose
        --threads 1
Input Points / Samples: 356630 / 88844
# Read input into tree: 0.1 (s), 43.7 (MB) / 92.8 (MB)
#   Got kernel density: 0.0 (s), 0.0 (MB) / 92.8 (MB)
#     Got normal field: 0.1 (s), 59.5 (MB) / 92.8 (MB)
Point depth / Point weight / Estimated measure: 9.37992 / 1.86572e-06 / 0.665373
#               Initialized envelope constraints: 1.7 (s), 155.3 (MB) / 202.4 (MB)
#Initialized point interpolation constraints: 0.0 (s), 0.0 (MB) / 202.4 (MB)
#       Finalized tree: 0.1 (s), 70.9 (MB) / 202.4 (MB)
#  Set FEM constraints: 0.4 (s), 76.9 (MB) / 202.4 (MB)
#Set point constraints: 0.0 (s), 67.1 (MB) / 202.4 (MB)
All Nodes / Active Nodes / Ghost Nodes / Dirichlet Supported Nodes: 563497 / 563112 / 385 / 58957
Memory Usage: 67.0586 MB
Cycle[0] Depth[5/8]:    Updated constraints / Got system / Solved in:  0.002 /  0.023 /  0.005  (202 MB)        Nodes: 6309
Cycle[0] Depth[6/8]:    Updated constraints / Got system / Solved in:  0.005 /  0.015 /  0.005  (202 MB)        Nodes: 30302
Cycle[0] Depth[7/8]:    Updated constraints / Got system / Solved in:  0.013 /  0.051 /  0.026  (202 MB)        Nodes: 133059
Cycle[0] Depth[8/8]:    Updated constraints / Got system / Solved in:  0.001 /  0.140 /  0.056  (202 MB)        Nodes: 318052
# Linear system solved: 0.4 (s), 80.1 (MB) / 202.4 (MB)
Got average: 0.0 (s), 64.6 (MB) / 202.4 (MB)
Iso-Value: 0.485563 = 173166 / 356630
[ERROR] C:\Research\PoissonRecon\PoissonRecon\Src\MyMiscellany.h (Line 359)
        FileBackedReadWriteStream::FileDescription::FileDescription
        Failed to open file:

I found an old issue here but I'm not sure if this issue is relevant to mine: https://github.com/mkazhdan/PoissonRecon/issues/101

PS: I have tried 16.01 and 16.04 version PoissonRecon.exe. Adding a --threads 1 has no effect to this problem.

YQGong commented 3 weeks ago

After replace _mktemp( fileName ); with an auto-increment integer string, the problem fixed. So I'm pretty sure the problem is the same as this one: https://github.com/mkazhdan/PoissonRecon/issues/101

mkazhdan commented 3 weeks ago

I was recently informed that switching the code: _mktemp( fileName ); fp = fopen( fileName , "w+b" ); if( !fp ) ERROR_OUT( "Failed to open file: " , fileName );

with: errno_t err = tmpfile_s(&fp); if (err != 0) { std::cerr << "tmpfile_s failed with error: " << err << std::endl; ERROR_OUT("Failed to create a unique temporary file."); }

resolves the problem. I have not had a chance to try it out yet (but I am also not generating the error). Not sure why this is issue has started surfacing recently.