本文整理汇总了C++中ArgParse::parse方法的典型用法代码示例。如果您正苦于以下问题:C++ ArgParse::parse方法的具体用法?C++ ArgParse::parse怎么用?C++ ArgParse::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgParse
的用法示例。
在下文中一共展示了ArgParse::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: benchmarks
static void
getargs(int argc, char* argv[])
{
bool help = false;
ArgParse ap;
// clang-format off
ap.options(
"fmath_test\n" OIIO_INTRO_STRING "\n"
"Usage: fmath_test [options]",
// "%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose mode",
// "--threads %d", &numthreads,
// ustring::sprintf("Number of threads (default: %d)", numthreads).c_str(),
"--iterations %d", &iterations,
ustring::sprintf("Number of values to convert for benchmarks (default: %d)", iterations).c_str(),
"--trials %d", &ntrials, "Number of trials",
nullptr);
// clang-format on
if (ap.parse(argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage();
exit(EXIT_FAILURE);
}
if (help) {
ap.usage();
exit(EXIT_FAILURE);
}
}
示例2: iterations
static void
getargs (int argc, char *argv[])
{
bool help = false;
ArgParse ap;
ap.options ("hash_test\n"
OIIO_INTRO_STRING "\n"
"Usage: hash_test [options]",
// "%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose mode",
"--iters %d", &iterations,
Strutil::format("Number of iterations (default: %d)", iterations).c_str(),
"--trials %d", &ntrials, "Number of trials",
NULL);
if (ap.parse (argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
exit (EXIT_FAILURE);
}
if (help) {
ap.usage ();
exit (EXIT_FAILURE);
}
}
示例3: threads
static void
getargs (int argc, char *argv[])
{
bool help = false;
ArgParse ap;
ap.options ("spin_rw_test\n"
OIIO_INTRO_STRING "\n"
"Usage: spin_rw_test [options]",
// "%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose mode",
"--threads %d", &numthreads,
ustring::format("Number of threads (default: %d)", numthreads).c_str(),
"--iters %d", &iterations,
ustring::format("Number of iterations (default: %d)", iterations).c_str(),
"--trials %d", &ntrials, "Number of trials",
"--rwratio %d", &read_write_ratio,
ustring::format("Reader::writer ratio (default: %d)", read_write_ratio).c_str(),
"--wedge", &wedge, "Do a wedge test",
NULL);
if (ap.parse (argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
exit (EXIT_FAILURE);
}
if (help) {
ap.usage ();
exit (EXIT_FAILURE);
}
}
示例4: mode
static void
getargs (int argc, const char *argv[])
{
bool help = false;
ArgParse ap;
ap.options ("Usage: testtex [options] inputfile",
"%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose status messages",
"-o %s", &output_filename, "Output test image",
"-d %s", &dataformatname, "Set the output data format to one of:"
"uint8, sint8, uint10, uint12, uint16, sint16, half, float, double",
"-res %d %d", &output_xres, &output_yres,
"Resolution of output test image",
"-iters %d", &iters,
"Iterations for time trials",
"--blur %f", &blur, "Add blur to texture lookup",
"--width %f", &width, "Multiply filter width of texture lookup",
"--fill %f", &fill, "Set fill value for missing channels",
"--wrap %s", &wrapmodes, "Set wrap mode (default, black, clamp, periodic, mirror, overscan)",
"--missing %f %f %f", &missing[0], &missing[1], &missing[2],
"Specify missing texture color",
"--autotile %d", &autotile, "Set auto-tile size for the image cache",
"--automip", &automip, "Set auto-MIPmap for the image cache",
"--blocksize %d", &blocksize, "Set blocksize (n x n) for batches",
"--handle", &use_handle, "Use texture handle rather than name lookup",
"--searchpath %s", &searchpath, "Search path for files",
"--nowarp", &nowarp, "Do not warp the image->texture mapping",
"--tube", &tube, "Make a tube projection",
"--cachesize %f", &cachesize, "Set cache size, in MB",
"--scale %f", &scalefactor, "Scale intensities",
"--maxfiles %d", &maxfiles, "Set maximum open files",
"--nountiled", &nountiled, "Reject untiled images",
"--nounmipped", &nounmipped, "Reject unmipped images",
"--ctr", &test_construction, "Test TextureOpt construction time",
"--gettexels", &test_gettexels, "Test TextureSystem::get_texels",
"--getimagespec", &test_getimagespec, "Test TextureSystem::get_imagespec",
"--offset %f %f %f", &offset[0], &offset[1], &offset[2], "Offset texture coordinates",
"--scalest %f %f", &sscale, &tscale, "Scale texture lookups (s, t)",
"--graytorgb", &gray_to_rgb, "Convert gratscale textures to RGB",
"--resetstats", &resetstats, "Print and reset statistics on each iteration",
NULL);
if (ap.parse (argc, argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
exit (EXIT_FAILURE);
}
if (help) {
ap.usage ();
exit (EXIT_FAILURE);
}
if (filenames.size() < 1) {
std::cerr << "testtex: Must have at least one input file\n";
ap.usage();
exit (EXIT_FAILURE);
}
}
示例5: main
int main(int argc, const char **argv)
{
util_logging_init(argv[0]);
path_init();
/* device types */
string devicelist = "";
string devicename = "cpu";
bool list = false, debug = false;
int threads = 0, verbosity = 1;
vector<DeviceType>& types = Device::available_types();
foreach(DeviceType type, types) {
if(devicelist != "")
devicelist += ", ";
devicelist += Device::string_from_type(type);
}
/* parse options */
ArgParse ap;
ap.options ("Usage: cycles_server [options]",
"--device %s", &devicename, ("Devices to use: " + devicelist).c_str(),
"--list-devices", &list, "List information about all available devices",
"--threads %d", &threads, "Number of threads to use for CPU device",
#ifdef WITH_CYCLES_LOGGING
"--debug", &debug, "Enable debug logging",
"--verbose %d", &verbosity, "Set verbosity of the logger",
#endif
NULL);
if(ap.parse(argc, argv) < 0) {
fprintf(stderr, "%s\n", ap.geterror().c_str());
ap.usage();
exit(EXIT_FAILURE);
}
if(debug) {
util_logging_start();
util_logging_verbosity_set(verbosity);
}
if(list) {
vector<DeviceInfo>& devices = Device::available_devices();
printf("Devices:\n");
foreach(DeviceInfo& info, devices) {
printf(" %s%s\n",
info.description.c_str(),
(info.display_device)? " (display)": "");
}
exit(EXIT_SUCCESS);
}
示例6: print
int
main (int argc, const char *argv[])
{
Filesystem::convert_native_arguments (argc, (const char **)argv);
ArgParse ap;
ap.options ("iinfo -- print information about images\n"
OIIO_INTRO_STRING "\n"
"Usage: iinfo [options] filename...",
"%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose output",
"-m %s", &metamatch, "Metadata names to print (default: all)",
"-f", &filenameprefix, "Prefix each line with the filename",
"-s", &sum, "Sum the image sizes",
"-a", &subimages, "Print info about all subimages",
"--hash", &compute_sha1, "Print SHA-1 hash of pixel values",
"--stats", &compute_stats, "Print image pixel statistics (data window)",
NULL);
if (ap.parse(argc, argv) < 0 || filenames.empty()) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
return EXIT_FAILURE;
}
if (help) {
ap.usage ();
exit (EXIT_FAILURE);
}
if (! metamatch.empty())
field_re.assign (metamatch,
boost::regex::extended | boost::regex_constants::icase);
// Find the longest filename
size_t longestname = 0;
BOOST_FOREACH (const std::string &s, filenames)
longestname = std::max (longestname, s.length());
longestname = std::min (longestname, (size_t)40);
long long totalsize = 0;
BOOST_FOREACH (const std::string &s, filenames) {
ImageInput *in = ImageInput::open (s.c_str());
if (! in) {
std::string err = geterror();
if (err.empty())
err = Strutil::format ("Could not open \"%s\"", s.c_str());
std::cerr << "iinfo: " << err << "\n";
continue;
}
ImageSpec spec = in->spec();
print_info (s, longestname, in, spec, verbose, sum, totalsize);
in->close ();
delete in;
}
示例7: param
static void
getargs (int argc, const char *argv[])
{
static bool help = false;
ArgParse ap;
ap.options ("Usage: testshade [options] shader...",
"%*", add_shader, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose messages",
"--debug", &debug, "Lots of debugging info",
"--stats", &stats, "Print run statistics",
"-g %d %d", &xres, &yres, "Make an X x Y grid of shading points",
"-o %L %L", &outputvars, &outputfiles,
"Output (variable, filename)",
"-od %s", &dataformatname, "Set the output data format to one of:\n"
"\t\t\t\tuint8, half, float",
"--layer %s", &layername, "Set next layer name",
"--fparam %L %L",
&fparams, &fparams,
"Add a float param (args: name value)",
"--iparam %L %L",
&iparams, &iparams,
"Add an integer param (args: name value)",
"--vparam %L %L %L %L",
&vparams, &vparams, &vparams, &vparams,
"Add a vector or color param (args: name x y z)",
"--sparam %L %L",
&sparams, &sparams,
"Add a string param (args: name value)",
"--connect %L %L %L %L",
&connections, &connections, &connections, &connections,
"Connect fromlayer fromoutput tolayer toinput",
"--raytype %s", &raytype, "Set the raytype",
"--iters %d", &iters, "Number of iterations",
"-O0", &O0, "Do no runtime shader optimization",
"-O1", &O1, "Do a little runtime shader optimization",
"-O2", &O2, "Do lots of runtime shader optimization",
// "-v", &verbose, "Verbose output",
NULL);
if (ap.parse(argc, argv) < 0 || shadernames.empty()) {
std::cerr << ap.error_message() << std::endl;
ap.usage ();
exit (EXIT_FAILURE);
}
if (help) {
std::cout <<
"testshade -- Test Open Shading Language\n"
"(c) Copyright 2009-2010 Sony Pictures Imageworks Inc. All Rights Reserved.\n";
ap.usage ();
exit (EXIT_SUCCESS);
}
}
示例8: re
int
main(int argc, const char* argv[])
{
Filesystem::convert_native_arguments(argc, argv);
ArgParse ap;
// clang-format off
ap.options ("igrep -- search images for matching metadata\n"
OIIO_INTRO_STRING "\n"
"Usage: igrep [options] pattern filename...",
"%*", parse_files, "",
"-i", &ignore_case, "Ignore upper/lower case distinctions",
"-v", &invert_match, "Invert match (select non-matching files)",
"-E", &extended_regex, "Pattern is an extended regular expression",
"-f", &file_match, "Match against file name as well as metadata",
"-l", &list_files, "List the matching files (no detail)",
"-r", &recursive, "Recurse into directories",
"-d", &print_dirs, "Print directories (when recursive)",
"-a", &all_subimages, "Search all subimages of each file",
"--help", &help, "Print help message",
NULL);
// clang-format off
if (ap.parse(argc, argv) < 0 || pattern.empty() || filenames.empty()) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
return EXIT_FAILURE;
}
if (help) {
ap.usage();
exit(EXIT_FAILURE);
}
#if USE_BOOST_REGEX
boost::regex_constants::syntax_option_type flag
= boost::regex_constants::grep;
if (extended_regex)
flag = boost::regex::extended;
if (ignore_case)
flag |= boost::regex_constants::icase;
#else
auto flag = std::regex_constants::grep;
if (extended_regex)
flag = std::regex_constants::extended;
if (ignore_case)
flag |= std::regex_constants::icase;
#endif
regex re(pattern, flag);
for (auto&& s : filenames)
grep_file(s, re);
return 0;
}
示例9: blocksize
static void
getargs (int argc, const char *argv[])
{
bool help = false;
ArgParse ap;
ap.options ("Usage: testtex [options] inputfile",
"%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose status messages",
"-o %s", &output_filename, "Output test image",
"-res %d %d", &output_xres, &output_yres,
"Resolution of output test image",
"-iters %d", &iters,
"Iterations for time trials",
"--blur %f", &blur, "Add blur to texture lookup",
"--width %f", &width, "Multiply filter width of texture lookup",
"--missing %f %f %f", &missing[0], &missing[1], &missing[2],
"Specify missing texture color",
"--autotile %d", &autotile, "Set auto-tile size for the image cache",
"--automip", &automip, "Set auto-MIPmap for the image cache",
"--blocksize %d", &blocksize, "Set blocksize (n x n) for batches",
"--handle", &use_handle, "Use texture handle rather than name lookup",
"--searchpath %s", &searchpath, "Search path for files",
"--nowarp", &nowarp, "Do not warp the image->texture mapping",
"--cachesize %f", &cachesize, "Set cache size, in MB",
"--scale %f", &scalefactor, "Scale intensities",
"--maxfiles %d", &maxfiles, "Set maximum open files",
"--nountiled", &nountiled, "Reject untiled images",
"--nounmipped", &nounmipped, "Reject unmipped images",
"--ctr", &test_construction, "Test TextureOpt construction time",
"--offset %f %f %f", &offset[0], &offset[1], &offset[2], "Offset texture coordinates",
"--scalest %f", &scalest, "Scale st coordinates",
NULL);
if (ap.parse (argc, argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
exit (EXIT_FAILURE);
}
if (help) {
ap.usage ();
exit (EXIT_FAILURE);
}
if (filenames.size() < 1) {
std::cerr << "testtex: Must have at least one input file\n";
ap.usage();
exit (EXIT_FAILURE);
}
}
示例10: difference
static void
getargs(int argc, char* argv[])
{
// clang-format off
bool help = false;
ArgParse ap;
ap.options ("idiff -- compare two images\n"
OIIO_INTRO_STRING "\n"
"Usage: idiff [options] image1 image2",
"%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose status messages",
"-q", &quiet, "Quiet (minimal messages)",
"-a", &compareall, "Compare all subimages/miplevels",
"<SEPARATOR>", "Thresholding and comparison options",
"-fail %g", &failthresh, "Failure threshold difference (0.000001)",
"-failpercent %g", &failpercent, "Allow this percentage of failures (0)",
"-hardfail %g", &hardfail, "Fail if any one pixel exceeds this error (infinity)",
"-warn %g", &warnthresh, "Warning threshold difference (0.00001)",
"-warnpercent %g", &warnpercent, "Allow this percentage of warnings (0)",
"-hardwarn %g", &hardwarn, "Warn if any one pixel exceeds this error (infinity)",
"-p", &perceptual, "Perform perceptual (rather than numeric) comparison",
"<SEPARATOR>", "Difference image options",
"-o %s", &diffimage, "Output difference image",
"-od", &outdiffonly, "Output image only if nonzero difference",
"-abs", &diffabs, "Output image of absolute value, not signed difference",
"-scale %g", &diffscale, "Scale the output image by this factor",
// "-meta", &comparemeta, "Compare metadata",
NULL);
if (ap.parse(argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
exit (EXIT_FAILURE);
}
if (help) {
ap.usage ();
exit (EXIT_FAILURE);
}
if (filenames.size() != 2) {
std::cerr << "idiff: Must have two input filenames.\n";
ap.usage();
exit (EXIT_FAILURE);
}
// clang-format on
}
示例11: exit
static void
getargs (int argc, char *argv[])
{
bool help = false;
ArgParse ap;
ap.options ("timer_test\n"
OIIO_INTRO_STRING "\n"
"Usage: timer_test [options]",
"%*", parse_files, "",
"--help", &help, "Print help message",
NULL);
if (ap.parse (argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
exit (EXIT_FAILURE);
}
if (help) {
ap.usage ();
exit (EXIT_FAILURE);
}
}
示例12: exit
static void
getargs (int argc, char *argv[])
{
bool help = false;
ArgParse ap;
ap.options ("iv -- image viewer\n"
OIIO_INTRO_STRING "\n"
"Usage: iv [options] [filename...]",
"%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose status messages",
"-F", &foreground_mode, "Foreground mode",
NULL);
if (ap.parse (argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
exit (EXIT_FAILURE);
}
if (help) {
ap.usage ();
exit (EXIT_FAILURE);
}
}
示例13: main
int main(int argc, const char** argv)
{
ArgParse::apflag showhelp = false;
ArgParse::apint myint = 0;
ArgParse ap;
ap.allowOneCharOptionsToBeCombined();
ap.usageHeader(ArgParse::apstring("Usage: ") + argv[0] + " [options]");
ap.argFlag("help", "\aprint this help, then exit", &showhelp);
ap.argInt("integer", "=value\aa random integer you can give for no reason",
&myint);
ap.alias("help", "h");
ap.alias("integer", "i");
if (!ap.parse(argc-1, argv+1))
{
Aqsis::log() << ap.errmsg() << std::endl << ap.usagemsg();
return 1;
}
if (ap.leftovers().size() > 0)
{
Aqsis::log() << "Extra crud \"" << ap.leftovers()[0] << "\" on command line";
Aqsis::log() << std::endl << ap.usagemsg();
return 1;
}
if (myint != 0)
{
cout << "Your favorite integer is " << myint << endl;
}
if (showhelp)
{
cout << ap.usagemsg();
return 0;
}
int bad = 0;
cout << "Testing flags and integers... ";
myint = 3;
showhelp = false;
int ok = 0;
const char* av[100];
if (ap.parse(0, av) && !showhelp && myint == 3 && ap.leftovers().size() == 0)
ok++;
av[0] = "-h";
if (ap.parse(1, av) && showhelp && myint == 3 && ap.leftovers().size() == 0)
ok++;
showhelp = false;
av[0] = "--help";
if (ap.parse(1, av) && showhelp && myint == 3 && ap.leftovers().size() == 0)
ok++;
showhelp = false;
av[0] = "--integer";
av[1] = "5";
if (ap.parse(2, av) && !showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
myint = 3;
av[0] = "-i";
if (ap.parse(2, av) && !showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
myint = 3;
av[2] = "--help";
if (ap.parse(3, av) && showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
av[0] = "-h";
av[1] = "-i";
av[2] = "5";
myint = 3;
showhelp = false;
if (ap.parse(3, av) && showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
av[0] = "-hi";
av[1] = "5";
myint = 3;
showhelp = false;
if (ap.parse(2, av) && showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
av[0] = "-hi=5";
myint = 3;
showhelp = false;
if (ap.parse(1, av) && showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
av[0] = "-help";
if (!ap.parse(1, av) &&
ap.errmsg() == "-help: 'e' is an unrecognized option")
ok++;
av[0] = "--integer=5";
//.........这里部分代码省略.........
示例14: threads
static void
getargs (int argc, char *argv[])
{
bool help = false;
ArgParse ap;
ap.options ("maketx -- convert images to tiled, MIP-mapped textures\n"
OIIO_INTRO_STRING "\n"
"Usage: maketx [options] file...",
"%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose status messages",
"-o %s", &outputfilename, "Output filename",
"-t %d", &nthreads, "Number of threads (default: #cores)",
"-u", &updatemode, "Update mode",
"--format %s", &fileformatname, "Specify output file format (default: guess from extension)",
"--nchannels %d", &nchannels, "Specify the number of output image channels.",
"-d %s", &dataformatname, "Set the output data format to one of: "
"uint8, sint8, uint16, sint16, half, float",
"--tile %d %d", &tile[0], &tile[1], "Specify tile size",
"--separate", &separate, "Use planarconfig separate (default: contiguous)",
// "--ingamma %f", &ingamma, "Specify gamma of input files (default: 1)",
// "--outgamma %f", &outgamma, "Specify gamma of output files (default: 1)",
// "--opaquewidth %f", &opaquewidth, "Set z fudge factor for volume shadows",
"--fov %f", &fov, "Field of view for envcube/shadcube/twofish",
"--fovcot %f", &fovcot, "Override the frame aspect ratio. Default is width/height.",
"--wrap %s", &wrap, "Specify wrap mode (black, clamp, periodic, mirror)",
"--swrap %s", &swrap, "Specific s wrap mode separately",
"--twrap %s", &twrap, "Specific t wrap mode separately",
"--resize", &doresize, "Resize textures to power of 2 (default: no)",
"--noresize", &noresize, "Do not resize textures to power of 2 (deprecated)",
"--filter %s", &filtername, filter_help_string().c_str(),
"--nomipmap", &nomipmap, "Do not make multiple MIP-map levels",
"--checknan", &checknan, "Check for NaN and Inf values (abort if found)",
"--Mcamera %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f",
&Mcam[0][0], &Mcam[0][1], &Mcam[0][2], &Mcam[0][3],
&Mcam[1][0], &Mcam[1][1], &Mcam[1][2], &Mcam[1][3],
&Mcam[2][0], &Mcam[2][1], &Mcam[2][2], &Mcam[2][3],
&Mcam[3][0], &Mcam[3][1], &Mcam[3][2], &Mcam[3][3],
"Set the camera matrix",
"--Mscreen %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f",
&Mscr[0][0], &Mscr[0][1], &Mscr[0][2], &Mscr[0][3],
&Mscr[1][0], &Mscr[1][1], &Mscr[1][2], &Mscr[1][3],
&Mscr[2][0], &Mscr[2][1], &Mscr[2][2], &Mscr[2][3],
&Mscr[3][0], &Mscr[3][1], &Mscr[3][2], &Mscr[3][3],
"Set the camera matrix",
"--hash", &embed_hash, "Embed SHA-1 hash of pixels in the header",
"--prman-metadata", &prman_metadata, "Add prman specific metadata",
"--constant-color-detect", &constant_color_detect, "Create 1-tile textures from constant color inputs",
"--monochrome-detect", &monochrome_detect, "Create 1-channel textures from monochrome inputs",
"--stats", &stats, "Print runtime statistics",
//FIXME "-c %s", &channellist, "Restrict/shuffle channels",
//FIXME "-debugdso"
//FIXME "-note %s", ¬e, "Append a note to the image comments",
"<SEPARATOR>", "Basic modes (default is plain texture):",
"--shadow", &shadowmode, "Create shadow map",
// "--shadcube", &shadowcubemode, "Create shadow cube (file order: px,nx,py,ny,pz,nz) (UNIMPLEMENTED)",
// "--volshad", &volshadowmode, "Create volume shadow map (UNIMP)",
"--envlatl", &envlatlmode, "Create lat/long environment map",
"--envcube", &envcubemode, "Create cubic env map (file order: px, nx, py, ny, pz, nz) (UNIMP)",
// "--lightprobe", &lightprobemode, "Convert a lightprobe to cubic env map (UNIMP)",
// "--latl2envcube", &latl2envcubemode, "Convert a lat-long env map to a cubic env map (UNIMP)",
// "--vertcross", &vertcrossmode, "Convert a vertical cross layout to a cubic env map (UNIMP)",
"<SEPARATOR>", "Configuration Presets",
"--prman", &prman, "Use PRMan-safe settings for tile size, planarconfig, and metadata.",
"--oiio", &oiio, "Use OIIO-optimized settings for tile size, planarconfig, metadata, and constant-color optimizations.",
NULL);
if (ap.parse (argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
exit (EXIT_FAILURE);
}
if (help) {
ap.usage ();
exit (EXIT_FAILURE);
}
full_command_line = ap.command_line ();
int optionsum = ((int)shadowmode + (int)shadowcubemode + (int)volshadowmode +
(int)envlatlmode + (int)envcubemode +
(int)lightprobemode + (int)vertcrossmode +
(int)latl2envcubemode);
if (optionsum > 1) {
std::cerr << "maketx ERROR: At most one of the following options may be set:\n"
<< "\t--shadow --shadcube --volshad --envlatl --envcube\n"
<< "\t--lightprobe --vertcross --latl2envcube\n";
ap.usage ();
exit (EXIT_FAILURE);
}
if (optionsum == 0)
mipmapmode = true;
if (doresize)
noresize = false;
if (prman && oiio) {
std::cerr << "maketx ERROR: '--prman' compatibility, and '--oiio' optimizations are mutually exclusive.\n";
std::cerr << "\tIf you'd like both prman and oiio compatibility, you should choose --prman\n";
std::cerr << "\t(at the expense of oiio-specific optimizations)\n";
ap.usage ();
exit (EXIT_FAILURE);
//.........这里部分代码省略.........
示例15: main
int main (int argc, const char* argv[])
{
bool generate = false;
bool extract = false;
int cubesize = 32;
int maxwidth = 2048;
std::string inputfile;
std::string outputfile;
std::string config;
std::string incolorspace;
std::string outcolorspace;
// TODO: Add optional allocation transform instead of colorconvert
ArgParse ap;
ap.options("ociolutimage -- Convert a 3dlut to or from an image\n\n"
"usage: ociolutimage [options] <OUTPUTFILE.LUT>\n\n"
"example: ociolutimage --generate --output lut.exr\n"
"example: ociolutimage --extract --input lut.exr --output output.spi3d\n",
"<SEPARATOR>", "",
"--generate", &generate, "Generate a lattice image",
"--extract", &extract, "Extract a 3dlut from an input image",
"<SEPARATOR>", "",
"--cubesize %d", &cubesize, "Size of the cube (default: 32)",
"--maxwidth %d", &maxwidth, "Specify maximum width of the image (default: 2048)",
"--input %s", &inputfile, "Specify the input filename",
"--output %s", &outputfile, "Specify the output filename",
"<SEPARATOR>", "",
"--config %s", &config, ".ocio configuration file (default: $OCIO)",
"--colorconvert %s %s", &incolorspace, &outcolorspace, "Apply a color space conversion to the image.",
NULL);
if (ap.parse(argc, argv) < 0)
{
std::cout << ap.geterror() << std::endl;
ap.usage();
std::cout << "\n";
return 1;
}
if (argc == 1 )
{
ap.usage();
std::cout << "\n";
return 1;
}
if(generate)
{
try
{
Generate(cubesize, maxwidth,
outputfile,
config, incolorspace, outcolorspace);
}
catch(std::exception & e)
{
std::cerr << "Error generating image: " << e.what() << std::endl;
exit(1);
}
catch(...)
{
std::cerr << "Error generating image. An unknown error occurred.\n";
exit(1);
}
}
else if(extract)
{
try
{
Extract(cubesize, maxwidth,
inputfile, outputfile);
}
catch(std::exception & e)
{
std::cerr << "Error extracting lut: " << e.what() << std::endl;
exit(1);
}
catch(...)
{
std::cerr << "Error extracting lut. An unknown error occurred.\n";
exit(1);
}
}
else
{
std::cerr << "Must specify either --generate or --extract.\n";
exit(1);
}
return 0;
}