mkazhdan / PoissonRecon

Poisson Surface Reconstruction
MIT License
1.59k stars 431 forks source link

Added CMake support #231

Open dbeef opened 2 years ago

dbeef commented 2 years ago

Once merged, Visual Studio solutions and Makefiles can be removed from repository.

Included build scripts for Windows and Ubuntu.

jiapei100 commented 2 years ago

Great job... ^_^ Thank you @dbeef Testing...

jiapei100 commented 2 years ago

Is it better to build PoissonRecon independently without building libpng, libjpeg, zlib as static libries??

mkazhdan commented 2 years ago

Those libraries are only there to support writing the implicit function (sampled on a grid) as an image in the case of 2D reconstruction. You can comment out that option in the code and then you won't need the libraries.

mkazhdan commented 2 years ago

However, if you do want to keep the image interface I would recommend keeping the libraries static. In particular, I believe the code was built using an older version of libpng and the newer version does not appear to be reverse compatible, so some of the function calls won't be declared/defined.

jiapei100 commented 2 years ago

@mkazhdan @dbeef

How did you manage to compile file https://github.com/mkazhdan/PoissonRecon/blob/master/Src/VertexFactory.inl and https://github.com/mkazhdan/PoissonRecon/blob/master/Src/PNG.inl ?

I failed to compile https://github.com/mkazhdan/PoissonRecon/blob/master/Src/VertexFactory.inl at coords[idx] , 10 occurences, with the following ERROR messages:

[ 50%] Building CXX object CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o
/usr/bin/c++   -O3 -DNDEBUG -DRELEASE -Ofast -funroll-loops -ffast-math -Wno-deprecated -Wno-invalid-offsetof -Wno-dangling-else -fPIE -std=c++14 -MD -MT CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o -MF CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o.d -o CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o -c ....../poisson-recon/Src/PoissonRecon.cpp
In file included from /usr/include/unistd.h:226,
                 from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from ....../poisson-recon/Src/MyMiscellany.h:250,
                 from ....../poisson-recon/Src/PoissonRecon.cpp:44:
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::PositionFactory<Real, Dim>::plyStaticReadProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:185:138: error: ‘idx’ is not a constant expression
  185 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::PositionFactory<Real, Dim>::plyStaticWriteProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:191:138: error: ‘idx’ is not a constant expression
  191 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::NormalFactory<Real, Dim>::plyStaticReadProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:221:138: error: ‘idx’ is not a constant expression
  221 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::NormalFactory<Real, Dim>::plyStaticWriteProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:227:138: error: ‘idx’ is not a constant expression
  227 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::TextureFactory<Real, Dim>::plyStaticReadProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:257:138: error: ‘idx’ is not a constant expression
  257 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::TextureFactory<Real, Dim>::plyStaticWriteProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:263:138: error: ‘idx’ is not a constant expression
  263 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::RGBColorFactory<Real>::plyStaticReadProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:293:142: error: ‘idx’ is not a constant expression
  293 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx%3] ) );
      |                                                                                                                                              ^
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::RGBColorFactory<Real>::plyStaticWriteProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:299:138: error: ‘idx’ is not a constant expression
  299 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::RGBAColorFactory<Real>::plyStaticReadProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:324:142: error: ‘idx’ is not a constant expression
  324 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx%3] ) );
      |                                                                                                                                              ^
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::RGBAColorFactory<Real>::plyStaticWriteProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:330:138: error: ‘idx’ is not a constant expression
  330 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
In file included from /usr/include/unistd.h:226,
                 from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from ....../poisson-recon/Src/MyMiscellany.h:250,
                 from ....../poisson-recon/Src/PoissonRecon.cpp:44:
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::PositionFactory<Real, Dim>::plyStaticReadProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:185:138: error: ‘idx’ is not a constant expression
  185 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::PositionFactory<Real, Dim>::plyStaticWriteProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:191:138: error: ‘idx’ is not a constant expression
  191 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::NormalFactory<Real, Dim>::plyStaticReadProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:221:138: error: ‘idx’ is not a constant expression
  221 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::NormalFactory<Real, Dim>::plyStaticWriteProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:227:138: error: ‘idx’ is not a constant expression
  227 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::TextureFactory<Real, Dim>::plyStaticReadProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:257:138: error: ‘idx’ is not a constant expression
  257 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::TextureFactory<Real, Dim>::plyStaticWriteProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:263:138: error: ‘idx’ is not a constant expression
  263 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::RGBColorFactory<Real>::plyStaticReadProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:293:142: error: ‘idx’ is not a constant expression
  293 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx%3] ) );
      |                                                                                                                                              ^
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::RGBColorFactory<Real>::plyStaticWriteProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:299:138: error: ‘idx’ is not a constant expression
  299 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::RGBAColorFactory<Real>::plyStaticReadProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:324:142: error: ‘idx’ is not a constant expression
  324 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx%3] ) );
      |                                                                                                                                              ^
....../poisson-recon/Src/VertexFactory.inl: In member function ‘PlyProperty VertexFactory::RGBAColorFactory<Real>::plyStaticWriteProperty(unsigned int) const’:
....../poisson-recon/Src/VertexFactory.inl:330:138: error: ‘idx’ is not a constant expression
  330 |                 return PlyProperty( _PlyNames[idx] , ToPlyType( _typeOnDisk ) , PLY::Type< Real >() , (int)offsetof( VertexType , coords[idx] ) );
      |                                                                                                                                          ^~~

and one additional failiure at file https://github.com/mkazhdan/PoissonRecon/blob/master/Src/PNG.inl , with ERROR:

In file included from ....../poisson-recon/Src/PNG.h:34,
                 from ....../poisson-recon/Src/Image.h:112,
                 from ....../poisson-recon/Src/PoissonRecon.cpp:50:
....../poisson-recon/Src/PNG.inl: In member function ‘virtual unsigned int PNGWriter::nextRows(const unsigned char*, unsigned int)’:
....../poisson-recon/Src/PNG.inl:148:138: error: invalid use of incomplete type ‘png_struct’ {aka ‘struct png_struct_def’}
  148 |         for( unsigned int r=0 ; r<rowNum ; r++ ) png_write_row( _png_ptr , (png_bytep)( rows + r * 3 * sizeof( unsigned char ) * _png_ptr->width ) );
      |                                                                                                                                          ^~
In file included from ....../poisson-recon/Src/PNG.h:4,
                 from ....../poisson-recon/Src/Image.h:112,
                 from ....../poisson-recon/Src/PoissonRecon.cpp:50:
/usr/include/png.h:454:16: note: forward declaration of ‘png_struct’ {aka ‘struct png_struct_def’}
  454 | typedef struct png_struct_def png_struct;
      |                ^~~~~~~~~~~~~~
In file included from ....../poisson-recon/Src/PNG.h:34,
                 from ....../poisson-recon/Src/Image.h:112,
                 from ....../poisson-recon/Src/PoissonRecon.cpp:50:
....../poisson-recon/Src/PNG.inl: In member function ‘virtual unsigned int PNGWriter::nextRows(const unsigned char*, unsigned int)’:
....../poisson-recon/Src/PNG.inl:148:138: error: invalid use of incomplete type ‘png_struct’ {aka ‘struct png_struct_def’}
  148 |         for( unsigned int r=0 ; r<rowNum ; r++ ) png_write_row( _png_ptr , (png_bytep)( rows + r * 3 * sizeof( unsigned char ) * _png_ptr->width ) );
      |                                                                                                                                          ^~
In file included from ....../poisson-recon/Src/PNG.h:4,
                 from ....../poisson-recon/Src/Image.h:112,
                 from ....../poisson-recon/Src/PoissonRecon.cpp:50:
/usr/include/png.h:454:16: note: forward declaration of ‘png_struct’ {aka ‘struct png_struct_def’}
  454 | typedef struct png_struct_def png_struct;
      |                ^~~~~~~~~~~~~~
^Cmake[2]: *** [CMakeFiles/PoissonReconApp.dir/build.make:79: CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o] Interrupt
make[2]: *** [CMakeFiles/PoissonRecon.dir/build.make:79: CMakeFiles/PoissonRecon.dir/Src/PoissonRecon.cpp.o] Interrupt
make[1]: *** [CMakeFiles/Makefile2:114: CMakeFiles/PoissonReconApp.dir/all] Interrupt
make[1]: *** [CMakeFiles/Makefile2:88: CMakeFiles/PoissonRecon.dir/all] Interrupt
make: *** [Makefile:139: all] Interrupt

Can you please help? Thank you ...

mkazhdan commented 2 years ago

This appears to do with the way in which the offsetof macro is defined. In Visual Studios it expands to:

if defined _MSC_VER && !defined _CRT_USE_BUILTIN_OFFSETOF

#ifdef __cplusplus
    #define offsetof(s,m) ((::size_t)&reinterpret_cast<char const volatile&>((((s*)0)->m)))
#else
    #define offsetof(s,m) ((size_t)&(((s*)0)->m))
#endif

else

#define offsetof(s,m) __builtin_offsetof(s,m)

endif

which does not require the second argument to be a constant.

It seems like your compiler's expansion of the macro assumes that it is constant, and hence the error that "coords[idx]" depends on "idx" which is not a compile time constant.

You can try defining a macro:

define my_offsetof(s,m) ((::size_t)&reinterpret_cast<char const volatile&>((((s*)0)->m)))

and then use "my_offsetof" instead of "offsetof".

dbeef commented 2 years ago

Hey @jiapei100, what does cc --version and uname -a return in your terminal? I second to what @mkazhdan says, it must be compiler-specific error, try updating to a more recent GCC/clang.

If you are Ubuntu based, see how update-alternatives works: https://askubuntu.com/questions/26498/how-to-choose-the-default-gcc-and-g-version

jiapei-nexera commented 2 years ago

@mkazhdan @dbeef

Hi, I'm using GCC 11.2.0 on Ubuntu 22.04 ...

➜  ~ gcc --version
gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

➜  ~ uname -r
5.15.0-41-generic
➜  ~ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:    22.04
Codename:   jammy
➜  ~ 

And I can tell in file CMakeLists.txt, there is a configuration for this offsetof as:

-Wno-invalid-offsetof.... Hmmm, NEVER used this before... What is that for? I believe GCC-11.2.0 for Ubuntu 22.04 has the configuration for offsetof, right???

jiapei-nexera commented 2 years ago

@mkazhdan @dbeef Now, I changed to clang, that offsetof issue is now gone... more or less a little weird to me... gcc is normally preferred by me .... But, I still have that png issue...

[ 50%] Building CXX object CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o
/usr/bin/clang++   -O3 -DNDEBUG -DRELEASE -Ofast -funroll-loops -ffast-math -Wno-deprecated -Wno-invalid-offsetof -Wno-dangling-else -fPIE -std=c++14 -MD -MT CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o -MF CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o.d -o CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o -c ....../poisson-recon/Src/PoissonRecon.cpp
In file included from ....../poisson-recon/Src/PoissonRecon.cpp:50:
In file included from ....../poisson-recon/Src/Image.h:112:
In file included from ....../poisson-recon/Src/PNG.h:34:
....../poisson-recon/Src/PNG.inl:148:131: error: member access into incomplete type 'png_struct' (aka 'png_struct_def')
        for( unsigned int r=0 ; r<rowNum ; r++ ) png_write_row( _png_ptr , (png_bytep)( rows + r * 3 * sizeof( unsigned char ) * _png_ptr->width ) );
                                                                                                                                         ^
In file included from ....../poisson-recon/Src/PoissonRecon.cpp:50:
In file included from ....../poisson-recon/Src/Image.h:112:
In file included from ....../poisson-recon/Src/PNG.h:34:
....../poisson-recon/Src/PNG.inl:148:131: error: member access into incomplete type 'png_struct' (aka 'png_struct_def')
        for( unsigned int r=0 ; r<rowNum ; r++ ) png_write_row( _png_ptr , (png_bytep)( rows + r * 3 * sizeof( unsigned char ) * _png_ptr->width ) );
                                                                                                                                         ^/usr/include/png.h
:454:16: note: forward declaration of 'png_struct_def'
typedef struct png_struct_def png_struct;
               ^
/usr/include/png.h:454:16: note: forward declaration of 'png_struct_def'
typedef struct png_struct_def png_struct;
               ^
dbeef commented 2 years ago

Judging by /usr/include/png.h, there is libpng already installed system-wise which conflicts with bundled libpng - I pushed a new commit where I prefix bundled libpng header with PNG/png.h, please try it.

mkazhdan commented 2 years ago

In PNG.inl, can you comment out line 6: "#include "?

jiapei-nexera commented 2 years ago

Current progress:

1) clang build hangs as follows:

➜  build git:(master) ✗ make -j16
/usr/bin/cmake -S....../poisson-recon -B....../poisson-recon/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start ....../poisson-recon/build/CMakeFiles ....../poisson-recon/build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '....../poisson-recon/build'
make  -f CMakeFiles/PoissonRecon.dir/build.make CMakeFiles/PoissonRecon.dir/depend
make  -f CMakeFiles/PoissonReconApp.dir/build.make CMakeFiles/PoissonReconApp.dir/depend
make[2]: Entering directory '....../poisson-recon/build'
cd ....../poisson-recon/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" ....../poisson-recon ....../poisson-recon ....../poisson-recon/build ....../poisson-recon/build ....../poisson-recon/build/CMakeFiles/PoissonRecon.dir/DependInfo.cmake --color=
make[2]: Entering directory '....../poisson-recon/build'
cd ....../poisson-recon/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" ....../poisson-recon ....../poisson-recon ....../poisson-recon/build ....../poisson-recon/build ....../poisson-recon/build/CMakeFiles/PoissonReconApp.dir/DependInfo.cmake --color=
make[2]: Leaving directory '....../poisson-recon/build'
make  -f CMakeFiles/PoissonRecon.dir/build.make CMakeFiles/PoissonRecon.dir/build
make[2]: Leaving directory '....../poisson-recon/build'
make  -f CMakeFiles/PoissonReconApp.dir/build.make CMakeFiles/PoissonReconApp.dir/build
make[2]: Entering directory '....../poisson-recon/build'
make[2]: Entering directory '....../poisson-recon/build'
[ 25%] Building CXX object CMakeFiles/PoissonRecon.dir/Src/PoissonRecon.cpp.o
/usr/bin/clang++ -DPoissonRecon_EXPORTS  -O3 -DNDEBUG -DRELEASE -Ofast -funroll-loops -ffast-math -Wno-deprecated -Wno-invalid-offsetof -Wno-dangling-else -fPIC -std=c++14 -MD -MT CMakeFiles/PoissonRecon.dir/Src/PoissonRecon.cpp.o -MF CMakeFiles/PoissonRecon.dir/Src/PoissonRecon.cpp.o.d -o CMakeFiles/PoissonRecon.dir/Src/PoissonRecon.cpp.o -c ....../poisson-recon/Src/PoissonRecon.cpp
[ 50%] Building CXX object CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o
/usr/bin/clang++   -O3 -DNDEBUG -DRELEASE -Ofast -funroll-loops -ffast-math -Wno-deprecated -Wno-invalid-offsetof -Wno-dangling-else -fPIE -std=c++14 -MD -MT CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o -MF CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o.d -o CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o -c ....../poisson-recon/Src/PoissonRecon.cpp
^Cmake[2]: *** [CMakeFiles/PoissonReconApp.dir/build.make:79: CMakeFiles/PoissonReconApp.dir/Src/PoissonRecon.cpp.o] Interrupt
make[2]: *** [CMakeFiles/PoissonRecon.dir/build.make:79: CMakeFiles/PoissonRecon.dir/Src/PoissonRecon.cpp.o] Interrupt
make[1]: *** [CMakeFiles/Makefile2:88: CMakeFiles/PoissonRecon.dir/all] Interrupt
make[1]: *** [CMakeFiles/Makefile2:114: CMakeFiles/PoissonReconApp.dir/all] Interrupt
make: *** [Makefile:139: all] Interrupt

2) Please refer to my modified CMakeLists.txt at https://github.com/jiapei-nexera/poisson-recon/blob/master/CMakeLists.txt .

Or, directly checkout my fork https://github.com/jiapei-nexera/poisson-recon, with trivial modification...

I'm now switching back to gcc for another try...

jiapei-nexera commented 2 years ago

According to GCC manual of my version 11.2.0 https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc.pdf, I got:

So, who has been deliberately make this piece of code nonportable ? or NOT platform-independent???

-Wno-invalid-offsetof (C++ and Objective-C++ only)
Suppress warnings from applying the offsetof macro to a non-POD type.
According to the 2014 ISO C++ standard, applying offsetof to a non-standardlayout type is undefined. In existing C++ implementations, however, offsetof
typically gives meaningful results. This flag is for users who are aware that
they are writing nonportable code and who have deliberately chosen to ignore
the warning about it.
The restrictions on offsetof may be relaxed in a future version of the C++
standard.
mkazhdan commented 2 years ago

Me.

jiapei-nexera commented 2 years ago

Successfully build libPoissonRecom.so out with my_offsetof .Thanks @mkazhdan .

However, I noticed that there a bunch of .cpp files containing main() function

Src/AdaptiveTreeVisualization.cpp:408:int main( int argc , char* argv[] )
Src/SurfaceTrimmer.cpp:584:int main( int argc , char* argv[] )
Src/ChunkPLY.cpp:546:int main( int argc , char* argv[] )
Src/ImageStitching.cpp:499:int main( int argc , char* argv[] )
Src/EDTInHeat.cpp:573:int main( int argc , char* argv[] )
Src/PoissonRecon.cpp:1064:int main( int argc , char* argv[] )
Src/PointInterpolant.cpp:928:int main( int argc , char* argv[] )
Src/SSDRecon.cpp:900:int main( int argc , char* argv[] )

Would it be a little better to separate them into a couple of folders ? Examples/Tests and Modules?

Seems to be doable... Let me try... a kind of deviated, but ....

BTW, how to thoroughly solve the problem of offsetof, without using self-defined my_offsetof ???

mkazhdan commented 2 years ago

More precisely, the codebase uses the .ply file format to support standard representations of geometry. That code was written back in the day, using C (where the offsetof macro was well-behaved and platform independent). To be able to continue using that library with PoissonRecon, which is written in C++, (without excessive re-writing) the decision was to continue using offsetof.

jiapei-nexera commented 2 years ago

@mkazhdan Wow... You are the author !!! ^_^

Now, I had the APP built ...Actually, there should 8 APPs, as my previous post. I'm actually import PoissonRecon with Open3D..

Let's see if there is any maintenance work that I can do ??

Thank you @mkazhdan

jiapei100 commented 2 years ago

@mkazhdan

Can you help to take a look at this pastebin ?

mkazhdan commented 2 years ago

I believe that the problem is that the non-default constructor for PlyFile: PlyFile( FILE f ) : fp(f) , other_elems(NULL) , version(1.) { } initializes "other_elems" before "version", while they are declared in the opposite order within the struct. You should be able to get around this by re-writing this as: PlyFile( FILE f ) : fp(f) , version(1.) , other_elems(NULL) { }

What compiler are you using? (I hadn't seen these errors before.)

gipeto commented 2 years ago

Judging by /usr/include/png.h, there is libpng already installed system-wise which conflicts with bundled libpng - I pushed a new commit where I prefix bundled libpng header with PNG/png.h, please try it.

In case updating to a more recent version of libpng did require only a few changes when I did try on my fork of the repo https://github.com/gipeto/AdaptiveMultiGridSolver/commit/48782081de49e43a99608a686026052de0b0df78 . I am consuming v.1.6.37 from conan, but doing the same with a submodule should be easy.

jiapei-nexera commented 2 years ago

@mkazhdan Can you please help to take a look at the ERRORs while I was trying to build Open3D with https://github.com/migr8/poisson-recon ?

Please refer to https://github.com/isl-org/Open3D/issues/5405

jiapei100 commented 2 years ago

I believe that the problem is that the non-default constructor for PlyFile: PlyFile( FILE f ) : fp(f) , other_elems(NULL) , version(1.) { } initializes "other_elems" before "version", while they are declared in the opposite order within the struct. You should be able to get around this by re-writing this as: PlyFile( FILE f ) : fp(f) , version(1.) , other_elems(NULL) { }

What compiler are you using? (I hadn't seen these errors before.)

Confirmed...

wamwamja commented 2 years ago

@jiapei100 @dbeef @mkazhdan As the error msg says, in some newer versions of libpng, png_struct is a forward declaration in png.h. To fix it, just replace _png_ptr->width with png_get_image_width(_png_ptr, _info_ptr) at line 148 in in PNG.inl, then it works.

mkazhdan commented 2 years ago

Thanks

DoMoCo commented 1 year ago

@dbeef Great job! Have you tested the efficiency of the code, I found that it is much slower than the makefile version

mattbolgercsiro commented 7 months ago

Hi @mkazhdan, we're very interested in using the latest version of this library (16.04) as part of wider CMake projects and see this PR seems to be the most coordinated effort for this but it's quite old and dormant for almost a year. Is there any expectation this would be merged eventually (and would therefore be the best basis to work from) or has it been abandoned, and we'd be just as wise to take a clean look at it with the latest code for our own needs?

mkazhdan commented 7 months ago

Unfortunately, I am not familiar enough with came to be able to merge and maintain it. So no plans to integrate in the immediate future.

jonringer commented 6 months ago

Would listing CMake as "community supported" be sufficient enough? similar to protobuf.

In general, I think people would be fine with sending in the odd PR to fix the CMake build. Don't need to add it to CI or some other gate which would impede your normal development workflow.

ahmadhasan2k8 commented 6 months ago

I made a PR with Cmake compatibility 7 years ago. Made some other changes to simply be able to call functions with samples here https://github.com/mkazhdan/PoissonRecon/pull/35 but I haven't maintained for ages. Seeing this, I think there are still people who would love to have cmake support. It would be great to merge either as long as there is cmake support. I haven't compared but if needed will be able to update the PR too. It's been a while

mkazhdan commented 6 months ago

Would listing CMake as "community supported" be sufficient enough? similar to protobuf.

In general, I think people would be fine with sending in the odd PR to fix the CMake build. Don't need to add it to CI or some other gate which would impede your normal development workflow.

What would be involved in doing this (both in terms of setting up initially, and maintaining moving forward) on my end?

jonringer commented 6 months ago

What would be involved in doing this (both in terms of setting up initially, and maintaining moving forward) on my end?

I would just be forward with "CMake is not officially supported, maintenance is delegated to the community". If you do get github issues, I would just cc myself and others who expressed interest in cmake support.

Non-entitled people should be fine with "I don't plan on supporting CMake, it's FOSS, if you want it, please help maintain it".

Teo7297 commented 4 months ago

Please @mkazhdan consider merging this PR. I could't build the master branch of this repo but with this commit on cmake I only needed to add #define NOMINMAX in PoissonRecon.cpp and everything went smooth.(with MSVC at least)