int main(int argc, char *argv[]) { ossimArgumentParser argumentParser(&argc, argv); ossimInit::instance()->addOptions(argumentParser); ossimInit::instance()->initialize(argumentParser); argumentParser.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); argumentParser.getApplicationUsage()->setApplicationName(argumentParser.getApplicationName()); argumentParser.getApplicationUsage()->setDescription(argumentParser.getApplicationName()+" GUI application for the ossim core library"); argumentParser.getApplicationUsage()->setCommandLineUsage(argumentParser.getApplicationName()+" [options]"); if (argumentParser.read("-h") || argumentParser.read("--help")) { argumentParser.getApplicationUsage()->write(std::cout); exit(0); } argumentParser.reportRemainingOptionsAsUnrecognized(); QApplication app(argc, argv); #ifdef OSSIMQT_USE_WINDOWS_STYLE QWindowsStyle *style = new QWindowsStyle(); app.setStyle(style); #endif ossimQtMainWindow* mainWindow = new ossimQtMainWindow(NULL, "ossimQtMainWindow"); app.setMainWidget(mainWindow); mainWindow->show(); int result = app.exec(); ossimInit::instance()->finalize(); return result; }
int main(int argc, char* argv[]) { ossimString tempString; ossimArgumentParser::ossimParameter stringParam(tempString); ossimArgumentParser argumentParser(&argc, argv); //ossimInit::instance()->addOptions(argumentParser); ossimInit::instance()->initialize(argumentParser); ossim_uint32 threads = 10; ossim_uint32 nvalues = 10; ossim_uint32 randomSeed = 0; argumentParser.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); argumentParser.getApplicationUsage()->addCommandLineOption("--threads","Specify the number of threads to test simultaneus access to elevation"); argumentParser.getApplicationUsage()->addCommandLineOption("--nvalues","Specify the number of random values"); if (argumentParser.read("-h") || argumentParser.read("--help")) { argumentParser.getApplicationUsage()->write(ossimNotify(ossimNotifyLevel_WARN)); exit(0); } if(argumentParser.read("--threads", stringParam)) { threads = tempString.toUInt32(); } if(argumentParser.read("--nvalues", stringParam)) { nvalues = tempString.toUInt32(); } std::vector<Polyarea2dThread*> threadList(threads); startBarrier = new OpenThreads::Barrier(threads); // include the main thread for synching endBarrier = new OpenThreads::Barrier(threads+1); // include main thread for syncing end ossim_uint32 idx = 0; for(idx = 0; idx < threads; ++ idx) { threadList[idx] = new Polyarea2dThread("Thread " + ossimString::toString(idx)); threadList[idx]->setNumberOfPointsToQuery(nvalues); threadList[idx]->start(); } ossimTimer::Timer_t t1 = ossimTimer::instance()->tick(); // synch all threads to start at the same time std::cout << "Number of threads: " << threads << "\n"; // startBarrier->block(); endBarrier->block(); std::cout << "All threads finished\n"; ossimTimer::Timer_t t2 = ossimTimer::instance()->tick(); std::cout << "Time elapsed: " << ossimTimer::instance()->delta_s(t1, t2) << " seconds" << "\n"; delete startBarrier; delete endBarrier; return 0; }
static PyObject * ossim_init(PyObject *self, PyObject *args) { char *pref_file; if (!PyArg_ParseTuple(args, "s", &pref_file)) return NULL; char *argv[] = {"ossim-height", "-P", pref_file}; int argc = 3; ossimArgumentParser argumentParser(&argc, argv); ossimInit::instance()->addOptions(argumentParser); ossimInit::instance()->initialize(argumentParser); argumentParser.getApplicationUsage()->setApplicationName( argumentParser.getApplicationName()); Py_RETURN_NONE; }
/** * the main progrems - calls the diffrent functions to start the orchestras * in case of success finding a solution or the best one - will print it * otherwise will print a message * @param argc the number of arguments give * @param argv the char array that hodls the arguments * return 0 **/ int main(int argc, char* argv[]) { atexit(cleanFiles); argumentParser(argc, argv); int** sudukuTable = NULL; sudukuTable = fileParser(sudukuTableFile); unsigned int best = ((gTableSize*(1 + gTableSize)) / 2)*gTableSize; pNode bestNode = getBest((pNode)sudukuTable, getNodeChildrenSoduku, calculateTableSum, nodeReleaser, copySudukuTable, best); if (bestNode != NULL) { printSudukuSolution((int**)bestNode, gTableSize); nodeReleaser(bestNode); } else { printf("no solution!\n"); } nodeReleaser(sudukuTable); return 0; }
bool do_processArguments(const int argc_in, ACE_TCHAR* argv_in[], // cannot be const... unsigned int& minRoomSize_out, bool& corridors_out, unsigned int& maxNumDoorsPerRoom_out, bool& level_out, bool& maximizeRoomSize_out, std::string& outputFile_out, bool& dump_out, unsigned int& numAreas_out, bool& squareRooms_out, bool& traceInformation_out, bool& printVersionAndExit_out, unsigned int& dimensionX_out, unsigned int& dimensionY_out, bool& random_out, Map_Generator_Options_t& options_out) { RPG_TRACE(ACE_TEXT("::do_processArguments")); std::string data_path = RPG_Common_File_Tools::getConfigurationDataDirectory (ACE_TEXT_ALWAYS_CHAR (BASEDIR), false); #if defined (DEBUG_DEBUGGER) data_path = Common_File_Tools::getWorkingDirectory (); #endif // init results minRoomSize_out = MAP_GENERATOR_DEF_MIN_ROOMSIZE; corridors_out = MAP_GENERATOR_DEF_CORRIDORS; level_out = MAP_GENERATOR_DEF_LEVEL; maxNumDoorsPerRoom_out = MAP_GENERATOR_DEF_MAX_NUMDOORS_PER_ROOM; maximizeRoomSize_out = MAP_GENERATOR_DEF_MAXIMIZE_ROOMSIZE; outputFile_out = data_path; outputFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A; #if defined (DEBUG_DEBUGGER) outputFile_out += ACE_TEXT_ALWAYS_CHAR("map"); outputFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A; outputFile_out += ACE_TEXT_ALWAYS_CHAR("data"); outputFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A; #else outputFile_out += ACE_TEXT_ALWAYS_CHAR(RPG_MAP_MAPS_SUB); outputFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A; #endif std::string default_output_path = outputFile_out; dump_out = MAP_GENERATOR_DEF_DUMP; numAreas_out = MAP_GENERATOR_DEF_NUM_AREAS; squareRooms_out = MAP_GENERATOR_DEF_SQUARE_ROOMS; traceInformation_out = false; printVersionAndExit_out = false; dimensionX_out = MAP_GENERATOR_DEF_DIMENSION_X; dimensionY_out = MAP_GENERATOR_DEF_DIMENSION_Y; random_out = false; options_out.clear(); ACE_Get_Opt argumentParser(argc_in, argv_in, ACE_TEXT("a::cd::lmo:pr:stvx:y:z")); int option = 0; std::stringstream converter; while ((option = argumentParser()) != EOF) { options_out.insert(static_cast<char>(option)); switch (option) { case 'a': { converter.clear(); converter.str(ACE_TEXT_ALWAYS_CHAR("")); converter << argumentParser.opt_arg(); converter >> minRoomSize_out; break; } case 'c': { corridors_out = true; break; } case 'd': { int temp = 0; converter.clear(); converter.str(ACE_TEXT_ALWAYS_CHAR("")); converter << argumentParser.opt_arg(); converter >> temp; if (temp == -1) maxNumDoorsPerRoom_out = std::numeric_limits<unsigned int>::max(); break; } case 'l': { level_out = true; break; } case 'm': { maximizeRoomSize_out = true; break; } case 'o': { outputFile_out = argumentParser.opt_arg(); break; } case 'p': { dump_out = true; break; } case 'r': { converter.clear(); converter.str(ACE_TEXT_ALWAYS_CHAR("")); converter << argumentParser.opt_arg(); converter >> numAreas_out; break; } case 's': { squareRooms_out = true; break; } case 't': { traceInformation_out = true; break; } case 'v': { printVersionAndExit_out = true; break; } case 'x': { converter.clear(); converter.str(ACE_TEXT_ALWAYS_CHAR("")); converter << argumentParser.opt_arg(); converter >> dimensionX_out; break; } case 'y': { converter.clear(); converter.str(ACE_TEXT_ALWAYS_CHAR("")); converter << argumentParser.opt_arg(); converter >> dimensionY_out; break; } case 'z': { random_out = true; break; } // error handling case ':': case '?': { ACE_DEBUG((LM_ERROR, ACE_TEXT("unrecognized option \"%s\", aborting\n"), ACE_TEXT(argumentParser.last_option()))); return false; } case 0: // long option default: { ACE_DEBUG((LM_ERROR, ACE_TEXT("unrecognized option \"%c\", aborting\n"), option)); return false; } } // end SWITCH } // end WHILE if (default_output_path == outputFile_out) { outputFile_out += (level_out ? RPG_Common_Tools::sanitize (ACE_TEXT_ALWAYS_CHAR (RPG_ENGINE_LEVEL_DEF_NAME)) : ACE_TEXT_ALWAYS_CHAR (RPG_MAP_DEF_MAP_FILE)); outputFile_out += (level_out ? ACE_TEXT_ALWAYS_CHAR (RPG_ENGINE_LEVEL_FILE_EXT) : ACE_TEXT_ALWAYS_CHAR (RPG_MAP_FILE_EXT)); } // end IF return true; }
int main(int argc, char* argv[]) { static const char MODULE[] = "band_merge:main"; std::string tempString; ossimArgumentParser::ossimParameter stringParam(tempString); ossimArgumentParser argumentParser(&argc, argv); ossimInit::instance()->addOptions(argumentParser); ossimInit::instance()->initialize(argumentParser); argumentParser.getApplicationUsage()->setApplicationName(argumentParser.getApplicationName()); argumentParser.getApplicationUsage()->setDescription(argumentParser.getApplicationName()+" merges band separate images to one image"); argumentParser.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); argumentParser.getApplicationUsage()->addCommandLineOption("-o or --create-overiew", "Creates and overview for the output image"); argumentParser.getApplicationUsage()->addCommandLineOption("-w or --tile-width", "Defines the tile width for the handlers that support tiled output"); if (traceDebug()) CLOG << " Entered..." << std::endl; if (argumentParser.read("-h") || argumentParser.read("--help")||(argumentParser.argc() < 2)) { argumentParser.getApplicationUsage()->write(std::cout); usage(); // for writer output types exit(0); } // Keyword list to initialize image writers with. ossimKeywordlist kwl; const char* PREFIX = "imagewriter."; ossim_uint32 tile_width = 32; bool create_overview = false; if (argumentParser.read("-o") || argumentParser.read("--crate-overview")) { create_overview = true; std::cout << "\nOutput overview building enabled." << std::endl; } if (argumentParser.read("-w", stringParam) || argumentParser.read("-tile-width", stringParam)) { tile_width = ossimString(tempString).toInt(); if ((tile_width % 16) != 0) { cerr << MODULE << " NOTICE:" << "\nTile width must be a multiple of 16!" << "\nDefaulting to 128" << std::endl; tile_width = 0; } std::cout << "Tile width set to: " << tile_width << std::endl; } argumentParser.reportRemainingOptionsAsUnrecognized(); // Three required args: output_type, input file, and output file. if (argumentParser.errors()) { argumentParser.writeErrorMessages(std::cout); exit(0); } if (argumentParser.argc() == 1) { argumentParser.getApplicationUsage()->write(std::cout); usage(); // for writer output types exit(0); } ossim_uint32 number_of_source_images = argumentParser.argc() - 3; if (traceDebug()) { CLOG << "DEBUG:" << "\nargc: " << argumentParser.argc() << "\nnumber_of_source_images: " << number_of_source_images << "\ntile_width: " << tile_width << "\ncreate_overview: " << (create_overview?"true":"false") << std::endl; } ossimString output_type = argv[1]; output_type.downcase(); std::cout << "Output type: " << output_type << std::endl; // Create the vector of image handlers. ossimConnectableObject::ConnectableObjectList ihs; for(ossim_uint32 h = 0; h < number_of_source_images; ++h) { ossimFilename f = argv[h + 2]; std::cout << "Input_image[" << h << "]: " << f << std::endl; ihs.push_back(ossimImageHandlerRegistry::instance()->open(f)); } // Get the output file. ossimFilename output_file = argv[argumentParser.argc() - 1]; std::cout << "Output file: " << output_file << std::endl; //--- // Set the output writer type and the image type. //--- kwl.add(PREFIX, ossimKeywordNames::TYPE_KW, output_type.c_str()); ossimRefPtr<ossimBandMergeSource> bm = new ossimBandMergeSource(ihs); ossimRefPtr<ossimImageFileWriter> fileWriter = ossimImageWriterFactoryRegistry::instance()->createWriter(kwl, PREFIX); if(!fileWriter) { bm->disconnect(); bm = 0; ossimConnectableObject::ConnectableObjectList::iterator i = ihs.begin(); while (i != ihs.end()) { (*i)->disconnect(); (*i) = 0; ++i; } cerr << "Error making an image writer..." << "\nExiting application..." << std::endl; exit(1); } // Write out a geometry file for new image. ossimKeywordlist bm_geom; ossimRefPtr<ossimImageGeometry> geom = bm->getImageGeometry(); geom->saveState(bm_geom); ossimFilename geom_file = output_file; geom_file.setExtension("geom"); bm_geom.write(geom_file); fileWriter->connectMyInputTo(0, bm.get()); if (tile_width) { // Set the tile size... fileWriter->setTileSize(ossimIpt(tile_width, tile_width)); } fileWriter->open(output_file); ossimStdOutProgress prog(2); fileWriter->addListener(&prog); fileWriter->setAreaOfInterest(bm->getBoundingRect()); if( fileWriter->canCastTo("ossimTiffWriter") ) { // ossimTiffWriter* twriter = PTR_CAST(ossimTiffWriter, fileWriter); if(fileWriter.valid()) { try { fileWriter->execute(); } catch(std::exception& e) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR exception caught:\n" << e.what() << std::endl; } catch (...) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR - Unknown exception caught!" << std::endl; } } } else if(fileWriter->canCastTo("ossimJpegWriter")) { ossimRefPtr<ossimScalarRemapper> remapper = NULL; if(PTR_CAST(ossimJpegWriter, fileWriter.get()) && (bm->getOutputScalarType() != OSSIM_UCHAR)) { remapper = new ossimScalarRemapper(bm.get(), OSSIM_UCHAR); remapper->initialize(); fileWriter->connectMyInputTo(0, remapper.get()); } fileWriter->initialize(); try { fileWriter->execute(); } catch(std::exception& e) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR exception caught:\n" << e.what() << std::endl; } catch (...) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR - Unknown exception caught!" << std::endl; } } else { try { fileWriter->execute(); } catch(std::exception& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR exception caught:\n" << e.what() << std::endl; } } catch (...) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR - Unknown exception caught!" << std::endl; } } } if (create_overview == true) { fileWriter->writeOverviewFile(); } fileWriter->disconnect(); fileWriter = 0; bm = 0; ossimConnectableObject::ConnectableObjectList::iterator it = ihs.begin(); while (it != ihs.end()) { (*it)->disconnect(); (*it) = 0; ++it; } exit(0); }
int main(int argc, char* argv[]) { ossimString tempString1; ossimString tempString2; ossimString tempString3; ossimString tempString4; ossimArgumentParser::ossimParameter tempParam1(tempString1); ossimArgumentParser::ossimParameter tempParam2(tempString2); ossimArgumentParser::ossimParameter tempParam3(tempString3); ossimArgumentParser::ossimParameter tempParam4(tempString4); ossimArgumentParser argumentParser(&argc, argv); ossimInit::instance()->addOptions(argumentParser); ossimInit::instance()->initialize(argumentParser); bool rpcFlag = false; bool cgFlag = false; bool enableElevFlag = true; bool enableAdjustmentFlag = true; ossimDrect imageRect; double error = .1; imageRect.makeNan(); argumentParser.getApplicationUsage()->setApplicationName(argumentParser.getApplicationName()); argumentParser.getApplicationUsage()->setDescription(argumentParser.getApplicationName() + " takes an input geometry (or image) and creates a converted output geometry"); argumentParser.getApplicationUsage()->setCommandLineUsage(argumentParser.getApplicationName() + " [options] <input file>"); argumentParser.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); argumentParser.getApplicationUsage()->addCommandLineOption("--rpc","Create an RPC projection"); argumentParser.getApplicationUsage()->addCommandLineOption("--rpc-gridsize","defines the grid size for the rpc estimate default is --rpc-gridsize=\"10 10\""); argumentParser.getApplicationUsage()->addCommandLineOption("--noelev","the projection but 0 out the elevation"); argumentParser.getApplicationUsage()->addCommandLineOption("--disable-adjustments","Current applies to coarse grid. It will try to make the grid adjustable if the input projection is adjustable"); argumentParser.getApplicationUsage()->addCommandLineOption("--cg","Create a coarse grid projection"); argumentParser.getApplicationUsage()->addCommandLineOption("--rect"," 4 values ulx uly width height"); argumentParser.getApplicationUsage()->addCommandLineOption("--tolerance","Used as an error tolerance. Currently on coarse grid uses it and is the pixel error for the estimate"); argumentParser.getApplicationUsage()->addCommandLineOption("--output","Override the default output name"); if (argumentParser.read("-h") || argumentParser.read("--help") || (argumentParser.argc() == 1)) { argumentParser.getApplicationUsage()->write(ossimNotify(ossimNotifyLevel_INFO)); ossimInit::instance()->finalize(); exit(0); } ossimFilename outputFile; ossimIpt rpcGridSize(10,10); if(argumentParser.read("--tolerance", tempParam1)) { error = tempString1.toDouble(); } if (argumentParser.read("--rpc")) { rpcFlag = true; } if (argumentParser.read("--rpc-gridsize",tempParam1, tempParam2)) { rpcGridSize.x = tempString1.toInt32(); rpcGridSize.y = tempString2.toInt32(); if(rpcGridSize.x < 1) { rpcGridSize.x = 8; } if(rpcGridSize.y < 1) { rpcGridSize.y = rpcGridSize.x; } } if (argumentParser.read("--cg")) { cgFlag = true; } if (argumentParser.read("--noelev")) { enableElevFlag = false; } if(argumentParser.read("--disable-adjustments")) { enableAdjustmentFlag = false; } if(argumentParser.read("--output", tempParam1)) { outputFile = ossimFilename(tempString1); } if(argumentParser.read("--rect", tempParam1,tempParam2,tempParam3,tempParam4 )) { double x,y,w,h; x = tempString1.toDouble(); y = tempString2.toDouble(); w = tempString3.toDouble(); h = tempString4.toDouble(); if(w < 1) w = 1; if(h < 1) h = 1; imageRect = ossimDrect(x,y,x+(w-1), y+(h-1)); } argumentParser.reportRemainingOptionsAsUnrecognized(); if (argumentParser.errors()) { argumentParser.writeErrorMessages(std::cout); exit(0); } ossimFilename file(argv[1]); ossimRefPtr<ossimImageHandler> h = ossimImageHandlerRegistry::instance()->open(file); ossimRefPtr<ossimProjection> inputProj = 0; ossimKeywordlist kwl; ossim_int32 minSpacing = 100; ossimRefPtr<ossimImageGeometry> geom; if(h.valid()) { geom = h->getImageGeometry(); imageRect = h->getBoundingRect(); } else if(!imageRect.hasNans()) { kwl.add(ossimKeywordNames::GEOM_FILE_KW, file.c_str()); inputProj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl); } if(!geom.valid()||!geom->getProjection()) { ossimNotify(ossimNotifyLevel_WARN) << "Unable to obtain an input projection. Returning " << std::endl; argumentParser.getApplicationUsage()->write(ossimNotify(ossimNotifyLevel_INFO)); } else if(!imageRect.hasNans()) { if(outputFile.empty()) { outputFile = file.setExtension("geom"); } if(rpcFlag) { ossimRefPtr<ossimRpcSolver> solver = new ossimRpcSolver(enableElevFlag); solver->solveCoefficients(imageRect, geom.get(), rpcGridSize.x, rpcGridSize.y); ossimRefPtr<ossimImageGeometry> outputProj = solver->createRpcProjection(); kwl.clear(); outputProj->saveState(kwl); kwl.write(outputFile); } else if(cgFlag) { ossimCoarseGridModel::setInterpolationError(error); ossimCoarseGridModel::setMinGridSpacing(minSpacing); ossimCoarseGridModel cg; cg.buildGrid(imageRect, inputProj.get(), 500.0, enableElevFlag, enableAdjustmentFlag); kwl.clear(); cg.saveState(kwl); kwl.write(outputFile); cg.saveCoarseGrid(outputFile.setExtension("dat")); } } else { ossimNotify(ossimNotifyLevel_WARN) << "Unable to find an image rect" << std::endl; } return 0; }
int main(int argc, char* argv[]) { #ifdef OSSIM_HAS_MPI # if OSSIM_HAS_MPI ossimMpi::instance()->initialize(&argc, &argv); if (ossimMpi::instance()->getRank() == 0) { ossimNotify(ossimNotifyLevel_INFO) << "MPI running with " << ossimMpi::instance()->getNumberOfProcessors() << " processors..." << std::endl; } # endif #endif std::string tempString; ossimArgumentParser::ossimParameter stringParam(tempString); ossimArgumentParser argumentParser(&argc, argv); ossimInit::instance()->addOptions(argumentParser); ossimInit::instance()->initialize(argumentParser); argumentParser.getApplicationUsage()->setApplicationName(argumentParser.getApplicationName()); argumentParser.getApplicationUsage()->setDescription(argumentParser.getApplicationName()+" flips any null pixels to a valid pixel"); argumentParser.getApplicationUsage()->setCommandLineUsage(argumentParser.getApplicationName()+" [options] <output_type> <input_file> <output_file> <target_value> <replacement_value>"); argumentParser.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); argumentParser.getApplicationUsage()->addCommandLineOption("-o or --create-overview", "Creates and overview for the output image"); argumentParser.getApplicationUsage()->addCommandLineOption("-c or --clamp-value", "clamp values (any pixel with value larger than input will be clamped to input)"); argumentParser.getApplicationUsage()->addCommandLineOption("-m", "Replacement mode (see notes below)"); argumentParser.getApplicationUsage()->addCommandLineOption("-w", "output tile width(only valid with tiled output types). Must be a multiply of 16"); static const char MODULE[] = "pixelflip:main"; if (traceDebug()) CLOG << " Entered..." << std::endl; ossimInit::instance()->initialize(argc, argv); // Keyword list to initialize image writers with. ossimKeywordlist kwl; const char* PREFIX = "imagewriter."; bool create_overview = false; ossim_int32 tile_width = 0; double clamp_value = 0.0; bool do_clamp = false; ossimPixelFlipper::ReplacementMode replacement_mode = ossimPixelFlipper::REPLACE_BAND_IF_TARGET; if(argumentParser.read("-h") || argumentParser.read("--help")||(argumentParser.argc() == 1)) { argumentParser.getApplicationUsage()->write(ossimNotify(ossimNotifyLevel_INFO)); usage(); exit(0); } while(argumentParser.read("-o") || argumentParser.read("--create-overview")) { create_overview = true; } while(argumentParser.read("-c", stringParam)) { clamp_value = ossimString(tempString).toDouble(); do_clamp = true; } while(argumentParser.read("-m", stringParam)) { ossimString mode = tempString; mode.downcase(); if (mode == "replace_band_if_target") { replacement_mode = ossimPixelFlipper::REPLACE_BAND_IF_TARGET; } else if (mode == "replace_band_if_partial_target") { replacement_mode = ossimPixelFlipper::REPLACE_BAND_IF_PARTIAL_TARGET; } else if (mode == "replace_all_bands_if_partial_target") { replacement_mode = ossimPixelFlipper::REPLACE_ALL_BANDS_IF_PARTIAL_TARGET; } else if (mode != "replace_all_targets") { ossimNotify(ossimNotifyLevel_WARN) << "Invalid mode: " << mode << "\nMode remains: replace_band_if_target" << std::endl; } } while(argumentParser.read("-w", stringParam)) { tile_width = ossimString(tempString).toInt32(); if (tile_width % 16) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " NOTICE:" << "\nTile width must be a multiple of 16!" << "\nDefaulting to 128" << std::endl; tile_width = 0; } } if(argumentParser.argc() != 6) { ossimMpi::instance()->finalize(); exit(0); } //*** // Set the writer type and the image type. //*** ossimString output_type = argumentParser.argv()[1]; output_type.downcase(); kwl.add(PREFIX, ossimKeywordNames::TYPE_KW, output_type.c_str()); // Get the input file. ossimFilename input_file = argumentParser.argv()[2]; // Get the output file. ossimFilename output_file = argumentParser.argv()[3]; // Get the value to replace. double target_value = ossimString(argumentParser.argv()[4]).toDouble(); // Get the replacement value. double replacement_value = ossimString(argumentParser.argv()[5]).toDouble(); bool master = true; if (ossimMpi::instance()->getRank() != 0) { master = false; } if (master) { ossimNotify(ossimNotifyLevel_INFO) << "pixelflip settings:" << "\noutput type: " << output_type << "\ninput file: " << input_file << "\noutput file: " << output_file << "\ntarget value: " << target_value << "\nreplacement value: " << replacement_value << std::endl; if (tile_width) { ossimNotify(ossimNotifyLevel_INFO) << "tile width: " << tile_width << std::endl; } if (do_clamp) { ossimNotify(ossimNotifyLevel_INFO) << "clamp value: " << clamp_value << std::endl; } } // Get an image handler for the input file. ossimRefPtr<ossimImageHandler> ih = ossimImageHandlerRegistry::instance()->open(ossimFilename(input_file)); if (!ih) { ossimNotify(ossimNotifyLevel_WARN) << "Unsupported image file: " << input_file << "\nExiting application..." << std::endl; ossimMpi::instance()->finalize(); exit(0); } // Initialize the if (ih->getErrorStatus() == ossimErrorCodes::OSSIM_ERROR) { ossimNotify(ossimNotifyLevel_WARN) << "Error reading image: " << input_file << "Exiting application..." << std::endl; ossimMpi::instance()->finalize(); exit(1); } ih->initialize(); if (traceDebug()) { CLOG << "DEBUG:" << "\nImage Handler: " << ih->getLongName() << std::endl; } // Capture the bounding rectangle of the image handler. ossimIrect output_rect = ih->getBoundingRect(0); // hook up the pixel flipper to the image handler. ossimRefPtr<ossimPixelFlipper> pf = new ossimPixelFlipper(); pf->connectMyInputTo(ih.get()); pf->initialize(); // Setup the pixel flipper target/replacement values, and replace mode. pf->setTargetValue(target_value); pf->setReplacementValue(replacement_value); pf->setReplacementMode(replacement_mode); // Setup pixel flipper clamp value if (do_clamp) { pf->setClampValue(clamp_value); } if (master) { ossimNotify(ossimNotifyLevel_INFO) << "replacement mode: " << pf->getReplacementModeString() << std::endl; } ossimImageSourceSequencer* sequencer = NULL; #ifdef OSSIM_HAS_MPI # if OSSIM_HAS_MPI // only allocate the slave connection if // the number of processors is larger than // 1 // if(ossimMpi::instance()->getNumberOfProcessors() > 1) { if(ossimMpi::instance()->getRank()!=0) { sequencer = new ossimImageMpiSWriterSequenceConnection(NULL, 4); } else { sequencer = new ossimImageMpiMWriterSequenceConnection(); } } else { sequencer = new ossimImageSourceSequencer(); } # else // we will just load a serial connection if MPI is not supported. sequencer = new ossimImageSourceSequencer(NULL); # endif #else sequencer = new ossimImageSourceSequencer(NULL); #endif ossimRefPtr<ossimImageWriter> writer = ossimImageWriterFactoryRegistry::instance()->createWriter(kwl, PREFIX); ossimImageFileWriter* fileWriter = PTR_CAST(ossimImageFileWriter, writer.get()); if( fileWriter == NULL ) { ossimNotify(ossimNotifyLevel_WARN) << "Error making an image writer..." << "\nExiting application..." << std::endl; ossimMpi::instance()->finalize(); exit(1); } // Change out the sequencer... fileWriter->changeSequencer(sequencer); // Hook up the pixel flipper to the file writer. fileWriter->connectMyInputTo(0, pf.get()); if (tile_width) { // Set the tile size... fileWriter->setTileSize(ossimIpt(tile_width, tile_width)); } fileWriter->open(output_file); // Add a listener to get percent complete. ossimStdOutProgress prog(0, true); fileWriter->addListener(&prog); if (fileWriter->getErrorStatus() == ossimErrorCodes::OSSIM_OK) { fileWriter->initialize(); fileWriter->setAreaOfInterest(output_rect); // Set the output rectangle. #ifdef OSSIM_HAS_MPI # if OSSIM_HAS_MPI double start_time = 0.0; if(ossimMpi::instance()->getRank() == 0) { start_time= MPI_Wtime(); } # endif #endif // Filter and write the file... fileWriter->execute(); #ifdef OSSIM_HAS_MPI # if OSSIM_HAS_MPI if(ossimMpi::instance()->getRank() == 0) { double stop_time = MPI_Wtime(); cout << "Elapsed time: " << (stop_time-start_time) << std::endl; } # endif #endif } else { cerr << "Error detected in the image writer..." << "\nExiting application..." << std::endl; exit(1); } if (create_overview == true) { fileWriter->writeOverviewFile(); } #ifdef OSSIM_HAS_MPI # if OSSIM_HAS_MPI ossimMpi::instance()->finalize(); # endif #endif exit(0); }
bool ossimPlanetQtApplication::initWithArgs(int& argc, char** argv) { osg::Texture::setMinimumNumberOfTextureObjectsToRetainInCache(0); osg::Drawable::setMinimumNumberOfDisplayListsToRetainInCache(0); //osg::DisplaySettings::instance()->setMaxNumberOfGraphicsContexts(1); if(getMaximumFiles() < 1024) { setMaximumFiles(1024); } // setMaximumFiles(25); //osgDB::DatabasePager* databasePager = osgDB::Registry::instance()->getOrCreateDatabasePager(); ossimArgumentParser argumentParser(&argc, argv); wmsInitialize(); ossimInit::instance()->setPluginLoaderEnabledFlag(false); ossimInit::instance()->initialize(argumentParser); osg::ArgumentParser arguments(&argumentParser.argc(),argumentParser.argv()); std::string tempString; osg::ArgumentParser::Parameter stringParam(tempString); addCommandLineOptions(arguments); if(arguments.read("-h") || arguments.read("--help")) { arguments.getApplicationUsage()->write(std::cout); return false; } // if(arguments.read("--enable-flatland")) // { // theLandType = ossimPlanetLandType_FLAT; // } if(arguments.read("--wms-timeout", stringParam)) { setWmsNetworkTimeoutInSeconds(ossimString(tempString).toDouble()); } if(arguments.read("--disable-elevation")) { // theElevEnabled = false; writePreferenceSetting("elev-flag", "false"); } if(arguments.read("--elev-estimation", stringParam)) { // theElevEstimate = 1<<ossimString(tempString.c_str()).toUInt32(); writePreferenceSetting("elev-patchsize", ossimString::toString(1<<ossimString(tempString.c_str()).toUInt32()).c_str()); } if(arguments.read("--elev-patchsize", stringParam)) { writePreferenceSetting("elev-patchsize", tempString.c_str()); // theElevEstimate = ossimString(tempString.c_str()).toUInt32(); } if(arguments.read("--elev-exag", stringParam)) { // theElevExag = ossimString(tempString.c_str()).toDouble(); writePreferenceSetting("elev-exag", tempString.c_str()); } if(arguments.read("--split-metric", stringParam)) { // theSplitMetricRatio = ossimString(tempString.c_str()).toDouble(); writePreferenceSetting("split-metric", tempString.c_str()); } if(arguments.read("--elev-cache", stringParam)) { // theElevCache = tempString.c_str(); writePreferenceSetting("elev-cache", tempString.c_str()); } if(arguments.read("--level-detail", stringParam)) { // theLevelOfDetail = ossimString(tempString.c_str()).toUInt32(); writePreferenceSetting("level-detail", tempString.c_str()); } if(arguments.read("--enable-hud")) { writePreferenceSetting("hud-flag", "true"); // theHudEnabled = true; } else if(arguments.read("--disable-hud")) { writePreferenceSetting("hud-flag", "false"); } // archive mapping enabled if( arguments.read("--enable-archive-mapping-enabled") ) { writePreferenceSetting("archive-mapping-enabled", "true"); } else if( arguments.read("--disable-archive-mapping-enabled") ) { writePreferenceSetting("archive-mapping-enabled", "false"); } if(arguments.read("--disable-mipmap")) { writePreferenceSetting("mipmap-flag", "false"); // theMipMapping = false; } if(arguments.read("--enable-mipmap")) { writePreferenceSetting("mipmap-flag", "true"); // theMipMapping = false; } arguments.reportRemainingOptionsAsUnrecognized(); if (arguments.errors()) { arguments.writeErrorMessages(std::cout); } ossimFilename currentPath = ossimFilename(argv[0]).path(); ossimFilename imageBundle; ossimFilename referenceImageBundle; ossimInit::instance()->setPluginLoaderEnabledFlag(true); // ossimString paths = ossimEnvironmentUtility::instance()->getEnvironmentVariable("OSSIM_ELEVATION_PATH"); // std::vector<ossimString> pathArray; // ossimString pathSeparator = ":"; osgDB::Registry::instance()->getDataFilePathList().push_back(theUserSupportDirectory.toStdString()); ossimFilename installDir = ossimEnvironmentUtility::instance()->getInstalledOssimSupportDir(); if(installDir.exists()) { osgDB::Registry::instance()->getDataFilePathList().push_back(installDir); } ossimFilename userDir = ossimEnvironmentUtility::instance()->getUserOssimSupportDir(); ossimFilename userImageDir = userDir.dirCat("images"); ossimFilename userDataDir = userDir.dirCat("data"); ossimFilename userImageReferenceDir = userImageDir.dirCat("reference"); ossimFilename installImageDir = installDir.dirCat("images"); ossimFilename installDataDir = installDir.dirCat("data"); ossimFilename instalImageReferenceDir = installImageDir.dirCat("reference"); userDir = userDir.dirCat("images"); userDir = userDir.dirCat("reference"); installDir = installDir.dirCat("images"); installDir = installDir.dirCat("reference"); // tmp drb // ossimFilename userStatePlaneFile = userDataDir.dirCat("state_plane.csv"); // ossimFilename installStatePlaneFile = installDataDir.dirCat("state_plane.csv"); // if(userStatePlaneFile.exists()) // { // allow state plane to override from user directory any installed state plane file. // ossimStatePlaneProjectionFactory::instance()->addCsvFile(userStatePlaneFile); // } #ifdef __MACOSX__ // test for a bundle // ossimFilename contentsFolder = currentPath.path(); // Check for embedded geoid grid nder the resource folder Resources/egm96.grd ossimFilename resourceFolder = contentsFolder.dirCat("Resources"); ossimFilename geoid1996File = resourceFolder.dirCat("egm96.grd"); ossimFilename statePlaneFile = resourceFolder.dirCat("state_plane.csv"); if(geoid1996File.exists()) { ossimRefPtr<ossimGeoid> geoid96 = new ossimGeoidEgm96; if(geoid96->open(geoid1996File, OSSIM_BIG_ENDIAN)) { ossimGeoidManager::instance()->addGeoid(geoid96.get()); } } // if(statePlaneFile.exists()) // { // ossimStatePlaneProjectionFactory::instance()->addCsvFile(statePlaneFile); // } // Check for embedded plugins and reference images ossimFilename resources = contentsFolder.dirCat("Resources"); ossimFilename ossimPluginsBundle = contentsFolder.dirCat("plugins"); ossimFilename osgPlugins = contentsFolder.dirCat("osgplugins"); referenceImageBundle = contentsFolder.dirCat("Resources"); imageBundle = referenceImageBundle.dirCat("images"); referenceImageBundle = imageBundle.dirCat("reference"); if(ossimPluginsBundle.exists()) { ossimInit::instance()->loadPlugins(ossimPluginsBundle); } if(osgPlugins.exists()) { osgDB::Registry::instance()->getLibraryFilePathList().push_front(osgPlugins); } if(resources.exists()) { osgDB::Registry::instance()->getDataFilePathList().push_front(resources); osgDB::Registry::instance()->getDataFilePathList().push_front(resources.dirCat("fonts")); } theThemePath = resourceFolder; theThemePath = theThemePath.dirCat("themes"); ossimFilename elevation = resourceFolder.dirCat("elevation"); if(elevation.exists()) { ossimElevManager::instance()->loadElevationPath(elevation); } // addLibraryPath(contentsFolder.dirCat("qtplugins").c_str()); #endif #ifdef WIN32 ossimFilename geoid = currentPath.dirCat("geoid1996"); ossimFilename geoid1996File = geoid.dirCat("egm96.grd"); if(!geoid1996File.exists()) { geoid = currentPath.dirCat("geoids"); geoid = geoid.dirCat("geoid1996"); geoid1996File = geoid.dirCat("egm96.grd"); } if(geoid1996File.exists()) { ossimRefPtr<ossimGeoid> geoid96 = new ossimGeoidEgm96; if(geoid96->open(geoid1996File, OSSIM_BIG_ENDIAN)) { ossimGeoidManager::instance()->addGeoid(geoid96.get()); } } ossimFilename osgPluginsBundle = currentPath.dirCat("osgplugins"); // ossimFilename ossimPluginsBundle = currentPath.dirCat("plugins"); referenceImageBundle = currentPath; imageBundle = referenceImageBundle.dirCat("images"); referenceImageBundle = imageBundle.dirCat("reference"); if(osgPluginsBundle.exists()) { osgDB::Registry::instance()->getLibraryFilePathList().push_back(osgPluginsBundle); } // if(ossimPluginsBundle.exists()) // { // ossimInit::instance()->loadPlugins(ossimPluginsBundle); // } ossimFilename elevation = currentPath.dirCat("elevation"); if(elevation.exists()) { ossimElevManager::instance()->loadElevationPath(elevation); } // pathSeparator = ";"; #endif ossimFilename dataDir = currentPath.dirCat("data"); // tmp drb // ossimFilename statePlane = dataDir.dirCat("state_plane.csv"); // if(statePlane.exists()) // { // ossimStatePlaneProjectionFactory::instance()->addCsvFile(statePlane); //} // we will now initialize any other plugins outside the bundle in standard locations // // if(installStatePlaneFile.exists()) // { // ossimStatePlaneProjectionFactory::instance()->addCsvFile(installStatePlaneFile); // } ossimInit::instance()->initializePlugins(); if(arguments.argc() > 1) { ossimKeywordlist kwl; if(kwl.addFile(arguments.argv()[1])) { osg::ref_ptr<ossimPlanetTextureLayer> layer = ossimPlanetTextureLayerRegistry::instance()->createLayer(kwl.toString()); if(layer.valid()) { layer->resetLookAt(); theReferenceImages.push_front(layer); } } } else { ossimFilename refFiles; if(userDir.exists()) { refFiles = userDir; } else if(installDir.exists()) { refFiles = installDir; } else if(referenceImageBundle.exists()) { refFiles = referenceImageBundle; } if(refFiles.exists()) { ossimDirectory dir; if(dir.open(refFiles)) { ossimFilename file; dir.getFirst(file); do { ossimString ext = file.ext(); if((ext != "ovr")&& (ext != "omd")&& (ext != "geom")&& (ext != "his")) { osg::ref_ptr<ossimPlanetTextureLayer> layer = ossimPlanetTextureLayerRegistry::instance()->createLayer(ossimString(file.c_str())); if(layer.valid()) { layer->resetLookAt(); theReferenceImages.push_front(layer); } } }while(dir.getNext(file)); } } } if(userImageDir.dirCat("compass.png").exists()) { theCompassRing = userImageDir.dirCat("compass.png"); } else if(imageBundle.dirCat("compass.png").exists()) { theCompassRing = imageBundle.dirCat("compass.png"); } else if(installImageDir.dirCat("compassring.png").exists()) { theCompassRing = installImageDir.dirCat("compassring.png"); //theCompassRose = installImageDir.dirCat("compassrose.png"); } else if(userImageDir.dirCat("compassring.png").exists()) { theCompassRing = userImageDir.dirCat("compassring.png"); //theCompassRose = userImageDir.dirCat("compassrose.png"); } else if(imageBundle.dirCat("compassring.png").exists()) { theCompassRing = imageBundle.dirCat("compassring.png"); //theCompassRose = imageBundle.dirCat("compassrose.png"); } else if(installImageDir.dirCat("compassring.png").exists()) { theCompassRing = installImageDir.dirCat("compassring.png"); //theCompassRose = installImageDir.dirCat("compassrose.png"); } if(autoHistogramStretchMode().isEmpty()) { setAutoHistogramStretchMode("Linear Auto Min Max"); } return true; }
//************************************************************************************************* // MAIN //************************************************************************************************* int main(int argc, char* argv[]) { ossimString tempString; double tempDouble, tempDouble2; ossimArgumentParser::ossimParameter stringParam(tempString); ossimArgumentParser::ossimParameter doubleParam(tempDouble); ossimArgumentParser::ossimParameter doubleParam2(tempDouble2); ossimArgumentParser argumentParser(&argc, argv); ossimInit::instance()->addOptions(argumentParser); ossimInit::instance()->initialize(argumentParser); argumentParser.getApplicationUsage()->setApplicationName(argumentParser.getApplicationName()); argumentParser.getApplicationUsage()->setDescription(argumentParser.getApplicationName()+ " Generates a bit-mask given source image and target pixel range to mask out. If the input" " image has overviews, then masks will be generated for all R-levels."); argumentParser.getApplicationUsage()->setCommandLineUsage(argumentParser.getApplicationName()+ " [options] <input file>"); argumentParser.getApplicationUsage()->addCommandLineOption("-d", "Write mask to directory specified."); argumentParser.getApplicationUsage()->addCommandLineOption("-e or --entry", "Give the entry(zero based) for which to build a mask. Only one entry can be processed. " "If the input is multi-entry and no entry was specified, entry 0 is assumed."); argumentParser.getApplicationUsage()->addCommandLineOption("-h or --help", "Shows help"); argumentParser.getApplicationUsage()->addCommandLineOption("--mask-mode <mode>", "Specifies how to treat multi-band imagery when determining whether pixel will be masked " "according to the defined target value or range. Possible modes are: " "\"mask_full_and_partial_targets\" (default) | \"mask_only_full_targets\"."); argumentParser.getApplicationUsage()->addCommandLineOption("--mask-range <min> <max>", "Specifies the range of pixels to target for masking out."); argumentParser.getApplicationUsage()->addCommandLineOption("--mask-value <target>", "Specifies the unique pixel value to target for masking out."); argumentParser.getApplicationUsage()->addCommandLineOption("-o", "Write mask to file specified. If used on a multi-entry file, given \"foo.mask\" you will " "get: \"foo_e0.mask\". If none specified, the input filename is used with \".mask\" " "extension."); argumentParser.getApplicationUsage()->addCommandLineOption("--ovr-from-image", "Uses exclusively the image overview data when computing subsequent overviews. " "Normally the mask overview from the prior level is referenced for establishing the masks at " "the next level."); argumentParser.getApplicationUsage()->addCommandLineOption("--spec-kwl <filename>", "In lieu of providing mask parameters on the command line, this option specifies a keyword " "list filename that contains all settings. Typically used when spawning from other process."); argumentParser.getApplicationUsage()->addCommandLineOption("-x or --exclude-fullres", "Excludes R0 mask computation. The mask file will start at R1."); if(argumentParser.read("-h") || argumentParser.read("--help")) { argumentParser.getApplicationUsage()->write(std::cout); finalize(0); } if ( argumentParser.read("--version") || argumentParser.read("-v")) { ossimNotify(ossimNotifyLevel_NOTICE)<< argumentParser.getApplicationName().c_str() << " " << ossimInit::instance()->instance()->version().c_str()<< std::endl; finalize(0); } // Fetch command line options: ossimFilename outputFile; if (argumentParser.read("-o", stringParam)) outputFile = tempString.trim(); ossimFilename outputDir; if (argumentParser.read("-d", stringParam)) outputDir = tempString.trim(); bool exclude_r0 = false; if (argumentParser.read("-x") || argumentParser.read("--exclude-fullres")) exclude_r0 = true; bool entry_specified = false; ossim_int32 entry = 0; if (argumentParser.read("-e", stringParam) || argumentParser.read("--entry", stringParam)) { entry = ossimString(tempString).toUInt32(); entry_specified = true; } double target_min = 0; double target_max = 0; if (argumentParser.read("--mask-range", doubleParam, doubleParam2)) { target_min = tempDouble; target_max = tempDouble2; } if (argumentParser.read("--mask-value", doubleParam)) { target_min = tempDouble; target_max = target_min; } ossimString mask_mode = "REPLACE_ALL_BANDS_IF_ANY_TARGET"; ossimString mask_mode_arg; if (argumentParser.read("--mask-mode", stringParam)) { mask_mode_arg = tempString; if (mask_mode_arg == "mask_full_and_partial_targets") mask_mode = "REPLACE_ALL_BANDS_IF_ANY_TARGET"; else if (mask_mode_arg == "mask_only_full_targets") mask_mode = "REPLACE_ONLY_FULL_TARGETS"; else { ossimNotify(ossimNotifyLevel_NOTICE)<< argumentParser.getApplicationName().c_str() << " " << " Unknown mask-mode <"<<mask_mode_arg<<"> specified. See usage below." << std::endl; argumentParser.getApplicationUsage()->write(std::cout); finalize(1); } } bool ovr_from_image = false; if (argumentParser.read("--ovr-from-image")) ovr_from_image = true; ossimFilename spec_kwl_file; if (argumentParser.read("--spec_kwl", stringParam)) spec_kwl_file = tempString.trim(); // Handle bad command line: argumentParser.reportRemainingOptionsAsUnrecognized(); if (argumentParser.errors()) { argumentParser.writeErrorMessages(std::cout); finalize(1); } if ((argumentParser.argc()<2) && spec_kwl_file.empty()) { argumentParser.getApplicationUsage()->write(std::cout); finalize(1); } // Establish input filename: ossimFilename inputFile; ossimKeywordlist kwl; if (spec_kwl_file.isReadable()) { kwl.addFile(spec_kwl_file); inputFile = kwl.find(ossimKeywordNames::IMAGE_FILE_KW); outputFile = kwl.find(ossimKeywordNames::OUTPUT_FILE_KW); } else { inputFile = argv[1]; } // Establish the input image handler: ossimRefPtr<ossimImageHandler> handler = ossimImageHandlerRegistry::instance()->open(inputFile); if (!handler.valid()) { ossimNotify(ossimNotifyLevel_FATAL)<<argumentParser.getApplicationName().c_str() <<" Error encountered opening input file <"<<inputFile<<">."<<endl; finalize(1); } // Establish output filename: if (outputFile.empty()) outputFile = handler->getFilenameWithThisExtension("mask", entry_specified); if (!outputDir.empty()) outputFile.setPath(outputDir); else { ossimFilename path (outputFile.path()); if (path.empty()) outputFile.setPath(inputFile.path()); } // Consider input file with multiple entries: std::vector<ossim_uint32> entryList; handler->getEntryList(entryList); if (entryList.size() <= entry) { ossimNotify(ossimNotifyLevel_FATAL)<<argumentParser.getApplicationName().c_str() <<" Entry specified <"<<entry<<"> exceeds total number of entries available <" <<entryList.size()<<">. Aborting..."<<endl; finalize(1); } handler->setCurrentEntry(entry); // Establish a keywordlist to pass to the mask builder. This KWL may have already been specified // on the command line with --spec_kwl option: kwl.add(ossimKeywordNames::OUTPUT_FILE_KW, outputFile.chars()); // may overwrite same value if (kwl.getSize() == 0) { kwl.add(ossimKeywordNames::IMAGE_FILE_KW, inputFile.chars()); ossimString target_str (ossimString::toString(target_min)+" "+ossimString::toString(target_max)); kwl.add(ossimPixelFlipper::PF_TARGET_RANGE_KW, target_str.chars()); kwl.add(ossimPixelFlipper::PF_REPLACEMENT_MODE_KW, mask_mode.chars()); kwl.add(ossimPixelFlipper::PF_REPLACEMENT_VALUE_KW, (int) 0); if (exclude_r0) kwl.add(ossimBitMaskWriter::BM_STARTING_RLEVEL_KW, (int) 1); else kwl.add(ossimBitMaskWriter::BM_STARTING_RLEVEL_KW, (int) 0); } // Instantiate the bit mask processor and write out the mask file: ossimRefPtr<ossimBitMaskWriter> mask_writer = new ossimBitMaskWriter; mask_writer->loadState(kwl); mask_writer->connectMyInputTo(handler.get()); // Need to loop over all R-levels. Use a sequencer: ossimRefPtr<ossimImageSourceSequencer> sequencer = new ossimImageSourceSequencer(handler.get()); sequencer->initialize(); int num_rlevels = handler->getNumberOfDecimationLevels(); int num_tiles = sequencer->getNumberOfTiles(); int tile_idx = 0; int percent_complete = 0; ossimRefPtr<ossimImageData> tile = 0; int start_res = 0; if (exclude_r0) { start_res = 1; num_tiles = (num_tiles+3)/4; } for (int r=start_res; r<num_rlevels; r++) { ossimNotify(ossimNotifyLevel_NOTICE)<<"\nProcessing R-level "<<r<<"... "<<endl; // Set the area of interest to the full image rectangle at this R-level: ossimIrect rect (handler->getBoundingRect(r)); sequencer->setAreaOfInterest(rect); sequencer->setToStartOfSequence(); do { tile = sequencer->getNextTile(r); mask_writer->generateMask(tile, r); percent_complete = 100 * tile_idx++/num_tiles; ossimNotify(ossimNotifyLevel_NOTICE)<<percent_complete<< "%\r"; } while(tile.valid()); tile_idx = 0; num_tiles = (num_tiles+3)/4; if (num_tiles == 0) num_tiles = 1; // Check if additional overviews are to be generated directly from the mask at first R-level: if ((r == start_res) && !ovr_from_image) { ossimNotify(ossimNotifyLevel_NOTICE)<<"\nBuilding remaining overviews from initial mask..." <<endl; mask_writer->buildOverviews(num_rlevels); break; } } // Finished sequencing all levels, ready to write out the mask buffers: mask_writer->close(); ossimNotify(ossimNotifyLevel_NOTICE)<<"\nSuccessfully wrote mask file to <"<<outputFile <<">. Finished."<<endl; finalize(0); }
const bool process_arguments(const int argc_in, ACE_TCHAR* argv_in[], // cannot be const... bool& printAllResults_out, RPG_Dice_ValueRange& valueRange_out, bool& traceInformation_out, bool& printVersionAndExit_out) { RPG_TRACE(ACE_TEXT("::process_arguments")); // init results printAllResults_out = false; valueRange_out.begin = 0; valueRange_out.end = 0; traceInformation_out = false; printVersionAndExit_out = false; ACE_Get_Opt argumentParser(argc_in, argv_in, ACE_TEXT_ALWAYS_CHAR("pr:tv")); int option = 0; while ((option = argumentParser()) != EOF) { switch (option) { case 'p': { printAllResults_out = true; break; } case 'r': { std::string range = argumentParser.opt_arg (); unsigned int separator = range.find_first_of (ACE_TEXT_ALWAYS_CHAR ("-"), 0); if (separator == std::string::npos) { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("invalid range: \"%s\", aborting\n"), ACE_TEXT (range.c_str ()))); return false; } // end IF valueRange_out.begin = ::atol (range.substr (0, separator).c_str ()); valueRange_out.end = ::atol (range.substr (separator + 1, range.length ()).c_str ()); if (valueRange_out.begin > valueRange_out.end) { std::swap (valueRange_out.begin, valueRange_out.end); } // end IF // // debug info // ACE_DEBUG((LM_DEBUG, // ACE_TEXT("range begin: %d, end: %d\n"), // valueRange_out.begin, // valueRange_out.end)); break; } case 't': { traceInformation_out = true; break; } case 'v': { printVersionAndExit_out = true; break; } // error handling case '?': { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("unrecognized option \"%s\", aborting\n"), ACE_TEXT (argumentParser.last_option ()))); return false; } default: { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("unrecognized option \"%c\", aborting\n"), option)); return false; } } // end SWITCH } // end WHILE return true; }
int main(int argc, char *argv[]) { ossimArgumentParser argumentParser(&argc, argv); ossimInit::instance()->addOptions(argumentParser); ossimInit::instance()->initialize(argumentParser); argumentParser.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); argumentParser.getApplicationUsage()->setApplicationName(argumentParser.getApplicationName()); argumentParser.getApplicationUsage()->setDescription(argumentParser.getApplicationName()+" GUI application for the ossim core library"); argumentParser.getApplicationUsage()->setCommandLineUsage(argumentParser.getApplicationName()+" [options]"); argumentParser.getApplicationUsage()->addCommandLineOption("-project","OPTIONAL: project file"); argumentParser.getApplicationUsage()->addCommandLineOption("No '-','*.gcl' file","untagged project file with 'gcl' extension"); if (argumentParser.read("-h") || argumentParser.read("--help")) { argumentParser.getApplicationUsage()->write(std::cout); exit(0); } // project file std::string tempString; ossimArgumentParser::ossimParameter stringParam(tempString); ossimString projFile; while(argumentParser.read("-project", stringParam)) { projFile = tempString; } // additional check for stand-alone ".gcl" project file // or list of images std::vector<ossimString> ilist; if (argc > 1) { for (int k=1; k<argc; ++k) { tempString = argv[k]; if (tempString.find(".gcl") != std::string::npos) { projFile = tempString; } else { ilist.push_back(tempString); } } } argumentParser.reportRemainingOptionsAsUnrecognized(); QApplication app(argc, argv); QSplashScreen splash(QPixmap(":/splash/GeoCellSplash.png")); splash.setWindowFlags(splash.windowFlags()|Qt::WindowStaysOnTopHint); splash.show(); #ifdef OSSIMQT_USE_WINDOWS_STYLE QWindowsStyle *style = new QWindowsStyle(); app.setStyle(style); #endif ossimObjectFactoryRegistry::instance()->registerFactory(ossimGui::OssimObjectFactory::instance()); ossimGui::MainWindow* mainWindow = new ossimGui::MainWindow(); // Load command line project file or image files if present if (projFile.size()>0) { mainWindow->loadProjectFile(projFile); } else if (ilist.size()>0) { mainWindow->loadImageFileList(ilist); } mainWindow->show(); OpenThreads::Thread::microSleep((1000*1000)); //splash.finish(mainWindow); splash.close(); int result = app.exec(); ossimInit::instance()->finalize(); return result; }