INSTALLATION

This library is known to work on Ubuntu 22.04 using g++ 10.5.0, but it will
likely work with other configurations, too.  Lines starting with "$" are bash
commands.  For the purposes of these instructions, we will assume that we are
installing into /home/user/PhysBAM.  You will need to adjust the paths
based on the actual installation location.

--------------------------------------------------------------------------------
PhysBAM setup
--------------------------------------------------------------------------------
1. Download the library.  This code requires version PhysBAM-0.

$ cd /home/user
$ wget https://www.cs.ucr.edu/~craigs/papers/physbam/PhysBAM-0.zip

2. Unpack the library:

$ unzip PhysBAM-0.zip

3. This extracts the library into a directory called PhysBAM, which in this case
is at /home/user/PhysBAM.  Next, we need to move the surface_reconstruction_nn
directory into Projects.

$ mv /path/to/surface_reconstruction_nn /home/user/PhysBAM/Projects/

4. Follow the library build instructions in /home/user/PhysBAM/README.txt.
Building the library automatically builds all projects located in the Projects
directory, so this project will be built automatically.

--------------------------------------------------------------------------------
Install libtorch C++
--------------------------------------------------------------------------------
$ cd /home/user
$ wget https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu118.zip
$ unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cu118.zip

Add to /home/user/PhysBAM/SConstruct.options:

LTDIR='/home/user/libtorch'
torch_enable=1
torch_includes=[LTDIR+'/include',LTDIR+'/include/torch/csrc/api/include']
torch_libpath=[LTDIR+'/lib']
torch_rpath=[LTDIR+'/lib']

--------------------------------------------------------------------------------
Install partio 
--------------------------------------------------------------------------------
$ cd /home/user
$ git clone https://github.com/wdas/partio.git
$ cd partio
$ make -j prefix=/home/user/pt install

Add to /home/user/PhysBAM/SConstruct.options:

PTDIR='/home/user/pt'
partio_enable=1
partio_includes=[PTDIR+'/include']
partio_libpath=[PTDIR+'/lib']
partio_rpath=[PTDIR+'/lib']

--------------------------------------------------------------------------------
Install openvdb c++ (need CMake 3.18 or higher)
--------------------------------------------------------------------------------
1. Download prerequisite packages
$ apt-get install -y libboost-iostreams-dev
$ apt-get install -y libtbb-dev
$ apt-get install -y libblosc-dev

2. Download openvdb
$ cd /home/user
$ wget https://github.com/AcademySoftwareFoundation/openvdb/archive/refs/tags/v10.1.0.zip
$ unzip v10.1.0.zip
$ cd openvdb-10.1.0
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/home/user/openvdb ..
$ make -j4 && make install

Add to /home/user/PhysBAM/SConstruct.options:

OPDIR='/home/user/openvdb'
openvdb_enable=1
openvdb_includes=[OPDIR+'/include']
openvdb_libpath=[OPDIR+'/lib']
openvdb_rpath=[OPDIR+'/lib']

--------------------------------------------------------------------------------
Install pytorch and tensorboard
--------------------------------------------------------------------------------
$ pip3 install torch
$ pip3 install tensorboard
$ pip3 install tensorboardX

# incompatibility jason parameter for some later versions >5
$ pip3 install protobuf==4.25.5

--------------------------------------------------------------------------------
Train and test model
--------------------------------------------------------------------------------
1. This code has been tested on NVIDIA Driver Version of 535 and CUDA Version
12.2, but might work with other configuration as ell, Adjust the batch_size or
the -P argument of xargs (maximum processes) if you encounter a CUDA out-of-memory
error. Rebuild the project after you modify the SConstruct.options file, then:

$ cd /home/user/PhysBAM/Projects/surface_reconstruction_nn
$ ./run_all.sh

results:
fixed-tests/test-*-out/vdb (surface)
fixed-tests/test-*-out/bgeo (particles)
       
--------------------------------------------------------------------------------
View training results
--------------------------------------------------------------------------------
$ tensorboard --logdir logs 

--------------------------------------------------------------------------------
View test results on Houdini
--------------------------------------------------------------------------------
File->Import->Geometry->path to bgeo/vdb files

vier surface using vdb:
1. double click imported vdb->tab->ConvertVdb, and connect it to vdb node.
2. Set ConvertTo to Polygons
2. set Adaptivity to 0.005 for better visual 

--------------------------------------------------------------------------------

