Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: CLI11 to replace Boost program option #373

Merged
merged 129 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
79cc842
add source CLI
kerautret Apr 20, 2020
5946fcb
First example remove boost prog option with CLI
kerautret Apr 20, 2020
e15cea8
Update doxygen from new CLI
kerautret Apr 20, 2020
e339bc9
test fix appveyor
kerautret Apr 21, 2020
1eeaffa
Update vol2vox.cpp
kerautret Apr 22, 2020
25ee82c
merge from master
kerautret May 23, 2020
9d190fe
CLI11 in volBoundary2obj
kerautret May 23, 2020
a991a91
merge
kerautret May 23, 2020
fc43834
CLI11 in vol2slice
kerautret May 24, 2020
4d6ff90
CLI11 in vol2sdp
kerautret May 24, 2020
526d536
CLI11 in vol2raw
kerautret May 24, 2020
585ae25
CLI11 in vol2obj
kerautret May 24, 2020
c1a6294
CLI11 in vol2heightfield
kerautret May 24, 2020
375e249
CLI11 in slice2vol
kerautret May 24, 2020
dfd1334
CLI11 in sdp2vol
kerautret May 24, 2020
5e6fb8e
CLI11 in raw2vol
kerautret May 25, 2020
0fcca65
CLI11 in raw2HDF5
kerautret May 25, 2020
596b949
merge
kerautret May 25, 2020
79ea12a
Fix vol2raw
kerautret May 25, 2020
87f7c19
CLI11 in ofs2off
kerautret May 25, 2020
2cafe2d
CLI11 in mesh2vol
kerautret May 25, 2020
6f10c1a
CLI11 in mesh2heightfield
kerautret May 25, 2020
84be973
merge
kerautret May 26, 2020
c91939b
CLI11 in longvol2vol
kerautret May 26, 2020
b14c8b8
merge
kerautret May 27, 2020
3263f40
CLI11 in itk2vol
kerautret May 27, 2020
87f35c2
CLI11 in imgAddNoise
kerautret May 27, 2020
a94bbee
CLI11 in img2freeman
kerautret May 27, 2020
928f9a4
CLI11 in heightfield2vol
kerautret May 28, 2020
5f8579e
CLI11 in heightfield2shading
kerautret May 30, 2020
1d1e142
CLI11 in freeman2sdp
kerautret May 30, 2020
f5db4a0
CLI11 in freeman2img
kerautret May 30, 2020
8d645fb
CLI11 in dicom2vol
kerautret May 31, 2020
ed4ffdc
CLI11 in convertVol
kerautret May 31, 2020
4b814c6
CLI11 in HDF52vol
kerautret May 31, 2020
ade9d72
CLI11 in vox2vol
kerautret May 31, 2020
4795895
CLI11 in vol2vox (finish)
kerautret May 31, 2020
00f0dc9
CLI11 in sliceViewer
kerautret Jun 1, 2020
1dadcd3
CLI11 in patternTriangulation
kerautret Jun 1, 2020
b36baf6
CLI11 in meshViewer
kerautret Jun 13, 2020
a001cc1
CLI11 in displayContours
kerautret Jun 14, 2020
c3c0f52
CLI11 in 3dVolViewer
kerautret Jun 14, 2020
dada505
CLI11 in volBoundaryViewer
kerautret Jun 14, 2020
66d3e3b
Merge branch 'master' into CLI11
kerautret Jun 14, 2020
57faf84
CLI11 in 3dSDPViewer
kerautret Jul 19, 2020
ed8c23a
merge from master
kerautret Jul 19, 2020
3adaeb6
merge from master
kerautret Jul 19, 2020
9ee9f46
CLI11 in 3dImplicitSurfaceExtractorByThickening
kerautret Jul 19, 2020
98730d1
3dImplicitSurfaceExtractorBy4DExtension
kerautret Jul 19, 2020
4fa4dc5
CLI11 in 3dImageViewer
kerautret Jul 19, 2020
a8c2d94
CLI11 in 3dHeightMapViewer
kerautret Jul 20, 2020
3060674
CLI11 in 3dDisplaySurfelData
kerautret Jul 21, 2020
76b0e2a
CLI11 in 3dCurveViewer
kerautret Jul 25, 2020
3ec15af
CLI11 in 3dCurvatureViewerNoise
kerautret Jul 29, 2020
98a35fe
CLI11 in 3dCurvatureViewer (and fix)
kerautret Jul 29, 2020
14dbba7
CLI11 in 3dCompSurfelData
kerautret Sep 8, 2020
a2af18f
CLI11 in 2dCompImage
kerautret Sep 8, 2020
09f25ac
Merge branch 'master' into CLI11
kerautret Sep 9, 2020
f3ed12b
CLI11 in 3dVolMarchingCubes
kerautret Sep 10, 2020
160c72d
merge from master
kerautret Sep 10, 2020
0787978
merge CLI11
kerautret Sep 10, 2020
f4150f8
CLI11 in criticalKernelsThinning3D
kerautret Sep 10, 2020
0782d36
test
ngophuc Sep 11, 2020
cced2f3
Merge pull request #81 from ngophuc/CLI11
kerautret Sep 11, 2020
41fbdb1
CLI11 in homotopicThinning3D
kerautret Sep 12, 2020
a40f2d9
merge from master
kerautret Sep 12, 2020
b8b7c67
CLI11 in volAddBorder
kerautret Sep 12, 2020
30361aa
doc typo in img2freeman
kerautret Sep 13, 2020
81646ad
back edit contourGenerator
kerautret Sep 13, 2020
4ca2bc7
CLI11 in volAddNoise
kerautret Sep 13, 2020
44f5b61
CLI11 in volCComponentCounter
kerautret Sep 13, 2020
1793707
CLI11 in volCrop
kerautret Sep 13, 2020
70b392b
CLI11 in volFillInterior
kerautret Sep 13, 2020
86e0076
CLI11 in volFlip
kerautret Sep 13, 2020
663ced3
CLI11 in volImageMetrics
kerautret Sep 13, 2020
8f6cbaf
CLI11 in volIntensityScale
kerautret Sep 13, 2020
41362f3
CLI11 in volReSample
kerautret Sep 13, 2020
2d8191e
CLI11 in volSegment
kerautret Sep 13, 2020
d18672e
modif rigidTransform2D.cpp
ngophuc Sep 13, 2020
fd03eae
modif rigidTransform2D.cpp
ngophuc Sep 13, 2020
ac43cde
Merge branch 'CLI11' of https://github.com/kerautret/DGtalTools into …
ngophuc Sep 13, 2020
7fa17f1
Merge pull request #82 from ngophuc/CLI11
kerautret Sep 13, 2020
3e0b45c
modif rigidTransform3D.cpp
ngophuc Sep 13, 2020
737ca9b
Merge branch 'CLI11' of https://github.com/kerautret/DGtalTools into …
ngophuc Sep 13, 2020
2cb453d
Merge pull request #83 from ngophuc/CLI11
kerautret Sep 13, 2020
c3736cf
CLI11 in volShapeMetrics
kerautret Sep 13, 2020
cafa3c9
merge from CLI11
kerautret Sep 13, 2020
bb33126
CLI11 in vvolSubSample
kerautret Sep 13, 2020
dad73f8
convert 3dParametricCurveDigitizer.cpp
ngophuc Sep 13, 2020
b4c1b09
convert 3dParametricCurveDigitizer.cpp
ngophuc Sep 13, 2020
108342e
convert contourGenerator.cpp
ngophuc Sep 13, 2020
99ca151
convert contourGenerator.cpp
ngophuc Sep 13, 2020
ec8f2c0
CLI11 in volTrValues
kerautret Sep 13, 2020
b9d119a
Merge pull request #84 from ngophuc/CLI11
kerautret Sep 13, 2020
6ad6f5d
convert shapeGenerator.cpp
ngophuc Sep 13, 2020
78173fc
convert shapeGenerator.cpp
ngophuc Sep 13, 2020
1090376
Merge pull request #85 from ngophuc/CLI11
kerautret Sep 13, 2020
ea8bf86
convert vol2normalField.cpp
ngophuc Sep 14, 2020
0776ae7
convert vol2normalField.cpp
ngophuc Sep 14, 2020
b735cbd
convert tangentBC.cpp
ngophuc Sep 14, 2020
b0956ba
convert statisticsEstimators.cpp
ngophuc Sep 14, 2020
3dc8ef6
convert lengthEstimators.cpp
ngophuc Sep 14, 2020
b22e38c
convert eulerCharacteristic.cpp
ngophuc Sep 14, 2020
46b7985
convert eulerCharacteristic.cpp
ngophuc Sep 14, 2020
f7130eb
convert curvatureScaleSpaceBCC.cpp
ngophuc Sep 14, 2020
bcc6f82
convert curvatureMCMS.cpp
ngophuc Sep 14, 2020
20207ba
Merge pull request #86 from ngophuc/CLI11
kerautret Sep 14, 2020
8900062
convert curvatureBC.cpp
ngophuc Sep 14, 2020
9f3ab49
Merge branch 'CLI11' of https://github.com/kerautret/DGtalTools into …
ngophuc Sep 14, 2020
c0bc73e
Merge pull request #87 from ngophuc/CLI11
kerautret Sep 14, 2020
25bbe39
convert 2dLocalEstimators.cpp
ngophuc Sep 14, 2020
274f5ec
Merge branch 'CLI11' of https://github.com/kerautret/DGtalTools into …
ngophuc Sep 14, 2020
5c4357b
Merge pull request #88 from ngophuc/CLI11
kerautret Sep 14, 2020
6ad8bdd
CLI11 in 3dCurveTangentEstimator
kerautret Sep 14, 2020
642b9b2
Lama doc typo
kerautret Sep 15, 2020
d84e4c4
CLI11 in 3dlocalEstimators
kerautret Sep 17, 2020
5c50e6c
CLI11 in volSurfaceRegularization
kerautret Sep 18, 2020
0fa6149
CLI11 in at-u0-v1
kerautret Sep 19, 2020
c724086
CLI11 in at-u2-v0
kerautret Sep 19, 2020
3099a5c
CLI11 in volMask
kerautret Sep 19, 2020
a15a5ca
CLI11 in atv-u2-v0
kerautret Sep 19, 2020
8dc28a7
Merge branch 'CLI11' of github.com:kerautret/DGtalTools into CLI11
kerautret Sep 19, 2020
9d759b5
Removing boost progr option in CMakeLists.txt 🎉
kerautret Sep 19, 2020
717a3e7
try fix appveyor
kerautret Sep 20, 2020
80f4e8d
try fix appveyor (again)
kerautret Sep 20, 2020
9eba9c6
try fix appveyor (again 2)
kerautret Sep 20, 2020
c1c8292
Changelog
kerautret Sep 20, 2020
27f7ece
Removing boost-PO in Travis
dcoeurjo Sep 21, 2020
b2c4437
Update ChangeLog.md
dcoeurjo Sep 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ addons:
- g++-4.8
- gcc-4.8
- libboost-dev
- libboost-program-options-dev
- libboost-system-dev

before_install:
- DOC="false"; BTYPE=""
- if [ $CONFIG == "DOCUMENTATION" ]; then DOC="true"; fi
Expand Down Expand Up @@ -97,5 +96,4 @@ deploy:
local-dir: "$TRAVIS_BUILD_DIR/html"
on:
branch: master
condition: [$DOC = "true"]

condition: [$DOC = "true"]
38 changes: 23 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ endif (CMAKE_CXX_FLAGS MATCHES "-ftemplate-depth-[0-9]*")



# CLI11
include_directories( "${PROJECT_SOURCE_DIR}/ext/" )



# -----------------------------------------------------------------------------
# Define variables and cmake parameters, and display some information
Expand All @@ -58,27 +62,31 @@ SET(DGTALTOOLS_VERSION "${DGtalTools_VERSION_MAJOR}.${DGtalTools_VERSION_MINOR}.
SET(PROJECT_VERSION "${DGtalTools_VERSION_MAJOR}.${DGtalTools_VERSION_MINOR}.${DGtalTools_VERSION_PATCH}")
SET(VERSION ${DGtalTools_VERSION_MAJOR}.${DGtalTools_VERSION_MINOR}.${DGtalTools_VERSION_PATCH})

OPTION(Boost_USE_STATIC_LIBS "Use boost static lib" ON)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
SET(Boost_FOUND FALSE)
FIND_PACKAGE(Boost 1.46.0 REQUIRED COMPONENTS program_options)




# -----------------------------------------------------------------------------
# Looking for boost
# -----------------------------------------------------------------------------

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_FOUND FALSE)
FIND_PACKAGE(Boost 1.50.0 REQUIRED)
if ( Boost_FOUND )
message(STATUS "Boost and boost_program_options found.")
ADD_DEFINITIONS(${BOOST_DEFINITIONS} -DBOOST_ALL_NO_LIB)
include_directories( ${Boost_INCLUDE_DIRS} )
ADD_DEFINITIONS(${BOOST_DEFINITIONS} -DBOOST_ALL_NO_LIB)
# SYSTEM to avoid warnings from boost.
include_directories(SYSTEM ${Boost_INCLUDE_DIRS} )
SET(DGtalToolsLibDependencies ${DGtalToolsLibDependencies}
${Boost_LIBRAIRIES}
${Boost_PROGRAM_OPTIONS_LIBRARY} Boost::program_options)
SET(DGtalLibInc ${Boost_INCLUDE_DIRS})
## Used to avoid ld warnings (to be removed when using CLI11 instead program_options)
if(APPLE)
set (CMAKE_CXX_FLAGS "-fvisibility=hidden")
endif(APPLE)
${Boost_LIBRAIRIES})
SET(DGtalLibInc ${Boost_INCLUDE_DIRS})
endif( Boost_FOUND )




# -----------------------------------------------------------------------------
# Documentation
# -----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# DGtalTools 1.1

- *global*
- New way to handle command line options of DGtalTools by using CLI11 instead boost program option.
(Bertrand Kerautret and Phuc Ngo
[#373](https://github.com/DGtal-team/DGtalTools/pull/373))
- Fix issue of link with boost program option. (Bertrand Kerautret
[#356](https://github.com/DGtal-team/DGtalTools/pull/356))
- set cmake based CPP11 check instead the manual DGtal check. (Bertrand
Expand Down
71 changes: 28 additions & 43 deletions converters/HDF52vol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@
#include <DGtal/images/Image.h>
#include <DGtal/images/ImageContainerBySTLVector.h>

#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
#include "CLI11.hpp"


using namespace std;
using namespace DGtal;
using namespace Z3i;

namespace po = boost::program_options;

/**
@page HDF52vol HDF52vol
Expand All @@ -52,9 +50,14 @@ namespace po = boost::program_options;
@b Allowed @b options @b are:

@code
-h [ --help ] display this message
-i [ --input ] arg the input FreemanChain file name
-o [ --output ] arg (=result.pgm) the output filename

Positionals:
1 TEXT:FILE REQUIRED volumetric file (.pgm3d, .vol, .longvol).

Options:
-h,--help Print this help message and exit
-i,--input TEXT:FILE REQUIRED the input FreemanChain file name
-o,--output TEXT the output filename
@endcode

@b Example:
Expand Down Expand Up @@ -83,49 +86,31 @@ void missingParam ( std::string param )
int main(int argc, char**argv)
{

// parse command line ----------------------------------------------
po::options_description general_opt ( "Allowed options are: " );
general_opt.add_options()
( "help,h", "display this message." )
( "input,i", po::value<std::string>(), "Input HDF5 file." )
( "output,o", po::value<string>(),"Output vol filename." );

bool parseOK=true;
po::variables_map vm;
try{
po::store(po::parse_command_line(argc, argv, general_opt), vm);
}catch(const std::exception& ex){
parseOK=false;
trace.info()<< "Error checking program options: "<< ex.what()<< endl;
}

po::notify ( vm );
if (!parseOK || vm.count ( "help" ) ||argc<=1 )
{
trace.info() << "Convert a 3D 8-bit HDF5 file to vol."<<std::endl
<< std::endl << "Basic usage: "<<std::endl
<< "\tHDF52vol --input <HDF5FileName> --output <VolOutputFileName> "<<std::endl
<< general_opt << "\n";
return 0;
}

//Parse options
if ( ! ( vm.count ( "input" ) ) ) missingParam ( "--input" );
std::string filename = vm["input"].as<std::string>();
if ( ! ( vm.count ( "output" ) ) ) missingParam ( "--output" );
std::string outputFileName = vm["output"].as<std::string>();


// parse command line using CLI ----------------------------------------------
CLI::App app;
std::string inputFileName;
std::string outputFileName {"result.vol"};

app.description("Convert a 3D 8-bit HDF5 file to vol.");
app.add_option("-i,--input,1", inputFileName, "Input HDF5 file." )
->required()
->check(CLI::ExistingFile);
app.add_option("-o,--output,2", outputFileName, "Output vol filename.", true );

app.get_formatter()->column_width(40);
CLI11_PARSE(app, argc, argv);
// END parse command line using CLI ----------------------------------------------

typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char> MyImageC;

MyImageC imageC = HDF5Reader< MyImageC >::importHDF5_3D( filename, "/UInt8Array3D" );
MyImageC imageC = HDF5Reader< MyImageC >::importHDF5_3D( inputFileName, "/UInt8Array3D" );
bool res = VolWriter< MyImageC>::exportVol(outputFileName, imageC);

if (res)
return 0;
return EXIT_SUCCESS;
else
{
trace.error()<< "Error while exporting the volume."<<std::endl;
return 1;
return EXIT_FAILURE;
}
}
82 changes: 28 additions & 54 deletions converters/convertVol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
#include "DGtal/io/readers/GenericReader.h"
#include "DGtal/io/writers/GenericWriter.h"


#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
#include "CLI11.hpp"

using namespace std;
using namespace DGtal;
Expand All @@ -46,15 +43,19 @@ using namespace DGtal;
@page convertVol convertVol
@brief Converts volumetric file into volumetric file from different formats (pgm3d, vol, longvol). This tool can also be used to upgrade a Version-2 Vol or Longvol file to the new (compressed) Version-3.


@b Usage: convertVol [input] [output]

@b Allowed @b options @b are:

@code
-h [ --help ] display this message
-i [ --input ] arg volumetric file (.pgm3d, .vol, .longvol)
-o [ --output ] arg volumetric file (.pgm3d, .vol, .longvol)
Positionals:
1 TEXT:FILE REQUIRED volumetric file (.pgm3d, .vol, .longvol).

Options:
-h,--help Print this help message and exit
-i,--input TEXT:FILE REQUIRED volumetric file (.pgm3d, .vol, .longvol).
-o,--output TEXT volumetric file (.pgm3d, .vol, .longvol)

@endcode

@b Examples:
Expand All @@ -73,60 +74,33 @@ using namespace DGtal;
*/


///////////////////////////////////////////////////////////////////////////////
namespace po = boost::program_options;

int main( int argc, char** argv )
{
typedef ImageContainerBySTLVector < Z3i::Domain, unsigned char> Image3D;

// parse command line ----------------------------------------------
po::options_description general_opt("Allowed options are: ");
general_opt.add_options()
("help,h", "display this message")
("input,i", po::value<std::string>(), "volumetric file (.pgm3d, .vol, .longvol) " )
("output,o", po::value<std::string>(), "volumetric file (.pgm3d, .vol, .longvol) " );

// parse command line using CLI ----------------------------------------------
CLI::App app;
std::string inputFileName;
std::string outputFileName {"result.vol"};

bool parseOK=true;
po::variables_map vm;
try{
po::store(po::parse_command_line(argc, argv, general_opt), vm);
}catch(const std::exception& ex){
parseOK=false;
trace.info()<< "Error checking program options: "<< ex.what()<< endl;
}
po::notify(vm);
if( !parseOK || vm.count("help")||argc<=1)
{
std::cout << "Usage: " << argv[0] << " [input] [output]\n"
<< "Convert volumetric file into volumetric file from different formats (pgm3d, vol, longvol) "
<< general_opt << "\n";
std::cout << "Example:\n"
<< "convertVol -i ${DGtal}/examples/samples/lobster.vol -o convertedVol.p3d \n";
return 0;
}

if(! vm.count("input")||! vm.count("output"))
{
trace.error() << " Input and output filename are needed to be defined" << endl;
return 0;
}


string inputFilename = vm["input"].as<std::string>();
string outputFilename = vm["output"].as<std::string>();

trace.info() << "Reading input file " << inputFilename ;
Image3D inputImage = DGtal::GenericReader<Image3D>::import(inputFilename);
app.description("Convert volumetric file into volumetric file from different formats (pgm3d, vol, longvol)\n ");
app.add_option("-i,--input,1", inputFileName, "volumetric file (.pgm3d, .vol, .longvol)." )
->required()
->check(CLI::ExistingFile);
app.add_option("-o,--output,2", outputFileName, "volumetric file (.pgm3d, .vol, .longvol)", true);

app.get_formatter()->column_width(40);
CLI11_PARSE(app, argc, argv);
// END parse command line using CLI ----------------------------------------------

trace.info() << "Reading input file " << inputFileName ;
Image3D inputImage = DGtal::GenericReader<Image3D>::import(inputFileName);
trace.info() << " [done] " << std::endl ;
trace.info() << "Writing output file " << outputFilename ;
DGtal::GenericWriter<Image3D>::exportFile(outputFilename, inputImage);
trace.info() << "Writing output file " << outputFileName ;
DGtal::GenericWriter<Image3D>::exportFile(outputFileName, inputImage);
trace.info() << " [done] " << std::endl ;


return 0;

return EXIT_SUCCESS;
}


Expand Down
Loading