display::Geometries get_interaction_graph_geometry(const InteractionGraph &ig) { display::Geometries ret; InteractionGraphConstVertexName vm = boost::get(boost::vertex_name, ig); InteractionGraphConstEdgeName em = boost::get(boost::edge_name, ig); boost::unordered_map<std::string, display::Color> colors; for (std::pair<InteractionGraphTraits::vertex_iterator, InteractionGraphTraits::vertex_iterator> be = boost::vertices(ig); be.first != be.second; ++be.first) { Particle *p = dynamic_cast<Particle *>(vm[*be.first]); core::XYZ pd(p); for (std::pair<InteractionGraphTraits::out_edge_iterator, InteractionGraphTraits::out_edge_iterator> ebe = boost::out_edges(*be.first, ig); ebe.first != ebe.second; ++ebe.first) { unsigned int target = boost::target(*ebe.first, ig); if (target > *be.first) continue; Particle *op = dynamic_cast<Particle *>(vm[target]); core::XYZ od(op); std::string on = em[*ebe.first]->get_name(); IMP_NEW(display::SegmentGeometry, cg, (algebra::Segment3D(pd.get_coordinates(), od.get_coordinates()))); if (colors.find(em[*ebe.first]->get_name()) == colors.end()) { colors[em[*ebe.first]->get_name()] = display::get_display_color(colors.size()); } cg->set_color(colors[em[*ebe.first]->get_name()]); cg->set_name(on); ret.push_back(cg.get()); } } return ret; }
int wb_dbms::del_family(wb_dbms_txn *txn, wb_dbms_cursor *cp, pwr_tOid poid) { int ret = 0; #if 0 dbName name; name.poid = poid; name.normname = ""; pwr_tOid oid = 0; FamilyKey nk(po, ); FamiltData nd(&oid, sizeof(oid)); wb_dbms_cursor *ncp; cp->dup(*ncp, 0); while ((ret = cp->get(&nk, &nd, DB_NEXT)) != DB_NOTFOUND) { del_family(txn, ncp, oid); cp->del(); oh_k ok(nd); oh_d od(); m_dbms_ohead->get(txn, &ok, &od, 0); wb_DbClistK ck(od); m_db_class->del(txn, &ck, 0); wb_DbBodyK bk(od); m_db_obody->del(txn, &bk, 0); m_db_ohead->del(txn, &ok, 0); } ncp->close(); ret = m_db_name->del(txn, &key, 0); #endif return ret; }
static int teasafe_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { auto openMode = teasafe::ReadOrWriteOrBoth::ReadWrite; /* if((fi->flags & O_RDWR) == O_RDWR) { openMode = teasafe::ReadOrWriteOrBoth::ReadWrite; }*/ auto appendType = teasafe::AppendOrOverwrite::Append; if ((fi->flags & O_APPEND) == O_APPEND) { appendType = teasafe::AppendOrOverwrite::Append; } auto truncateType = teasafe::TruncateOrKeep::Keep; if ((fi->flags & O_TRUNC) == O_TRUNC) { truncateType = teasafe::TruncateOrKeep::Truncate; } teasafe::OpenDisposition od(openMode, appendType, teasafe::CreateOrDontCreate::Create, truncateType); auto device(TeaSafe_DATA->openFile(path, od)); device.seek(offset, std::ios_base::beg); auto written = device.write(buf, size); if(written < 0) { return 0; } return written; }
int main (int argc, char** argv) { // Initialize ROS ros::init (argc, argv, "object_detection"); ros::NodeHandle nh("~"); int HZ; nh.getParam("HZ", HZ); ObjectDetector od(&nh); // Create a ROS subscriber for the input point cloud ros::Subscriber sub = nh.subscribe("/camera/depth/points", 1, &ObjectDetector::cloud_cb, &od); // Create ROS publisher pub = nh.advertise<pcl_msgs::Clusters> ("/pcl/cluster", 1); // Spin ros::Rate loop_rate(HZ); while (ros::ok()){ ros::spinOnce(); loop_rate.sleep(); } }
UINT CSmartFieldsDialog::OnGetDlgCode() { UINT uRet = CDialog::OnGetDlgCode(); od("Dialog: OnGetDlgCode (%x)\r\n", uRet); return uRet; }
bool ExportFFmpeg::DisplayOptions(wxWindow *parent, int format) { if (!CheckFFmpegPresence()) return false; // subformat index may not correspond directly to fmts[] index, convert it mSubFormat = AdjustFormatIndex(format); if (mSubFormat == FMT_M4A) { ExportFFmpegAACOptions od(parent); od.ShowModal(); return true; } else if (mSubFormat == FMT_AC3) { ExportFFmpegAC3Options od(parent); od.ShowModal(); return true; } else if (mSubFormat == FMT_AMRNB) { ExportFFmpegAMRNBOptions od(parent); od.ShowModal(); return true; } else if (mSubFormat == FMT_WMA2) { ExportFFmpegWMAOptions od(parent); od.ShowModal(); return true; } else if (mSubFormat == FMT_OTHER) { ExportFFmpegOptions od(parent); od.ShowModal(); return true; } return false; }
LPVOID StandardHeap::reallocate(LPVOID memory, HEAP_ELEMENT_SIZE new_size, HEAP_ELEMENT_SIZE old_size) { LPVOID new_mem; #ifdef DEBUG_HEAP HEAP_ELEMENT_SIZE debug_old_size; if (memory == NULL) { debug_old_size = 0L; } else { debug_old_size = ::_msize(memory); } #endif // if ((new_mem = ::realloc(memory, new_size)) == NULL) { // HEAP_ELEMENT_SIZE old_size = ::_msize(memory); /* Couldn't reallocate in place. Try to reallocate by moving. */ if ((new_mem = allocate(new_size)) != NULL) { /* Success! Copy the data over. */ if (memory != NULL) { memcpy(new_mem, memory, __min(new_size, old_size)); /* Free the old memory since we succeeded. */ free(memory); } } } #ifdef DEBUG_HEAP HEAP_ELEMENT_SIZE debug_new_size = ::_msize(new_mem); /* Do NOT combine these next two lines! SIGNED/UNSIGNED problems! */ dwAllocated -= debug_old_size; dwAllocated += debug_new_size; od("Realloc'ed %x to %x bytes (%lx)\r\n", debug_old_size, debug_new_size, dwAllocated); #endif freed = TRUE; // od("realloc %u got %lx\r\n", new_size, new_mem); return new_mem; }
VOID StandardHeap::free(LPVOID memory) { #ifdef DEBUG_HEAP if (memory != NULL) { HEAP_ELEMENT_SIZE size = ::_msize(memory); dwAllocated -= size; od("free: %x @ %08lx (%lx)\r\n", size, memory, dwAllocated); } #endif // ::free(memory); delete [] (LPBYTE)memory; freed = TRUE; }
inline arma::vec inferAncestry(const arma::vec& x,const arma::mat& A) { arma::mat od=arma::ones(x.n_elem+1,1); od(0)=1.0; for(int i=0;i<x.n_elem;i++) { od(i+1)=x(i); } arma::vec ret=A*od; for(int i=0;i<ret.n_elem;i++) { if(ret(i)<0)ret(i)=0; } double norm=arma::norm(ret,1); for(int i=0;i<ret.n_elem;i++) { ret(i)=ret(i)/norm; } return ret; }
bool TestRender::option( const std::vector<std::string>& optionString ) { options::options_description od("Usage: DPTApp"); od.add_options() ( "width", options::value<unsigned int>()->default_value(1024), "Width of the render window" ) ( "height", options::value<unsigned int>()->default_value(768), "Height of the render window" ) ( "renderer", options::value<std::string>(), "The renderer that will be used" ) ( "backend", options::value<std::string>(), "The backend to use" ) ; options::basic_parsed_options<char> parsedOpts = options::basic_command_line_parser<char>( optionString ).options( od ).allow_unregistered().run(); options::variables_map optsMap; options::store( parsedOpts, optsMap ); // Width m_width = optsMap["width"].as<unsigned int>(); // Height m_height = optsMap["height"].as<unsigned int>(); // All additional options std::vector<std::string> possibleRendererOptions = options::collect_unrecognized( parsedOpts.options, options::include_positional ); // Backend if( !optsMap["backend"].empty() ) { m_backendName = optsMap["backend"].as<std::string>(); } // Renderer if( optsMap["renderer"].empty() ) { std::cerr << "Error: A renderer must be specified\n"; return false; } else { m_backend = createBackend( optsMap["renderer"].as<std::string>(), possibleRendererOptions ); m_rendererSpecified = true; } return !!m_backend; }
void MyProcessingClass::tests() { Coordinate<int> c(2,3); std::cout <<c.toString() ; c.setFirst(5); c.setSecond(7); std::cout << c.toString(); Sizei s(1,2); std::cout << s.toString(); OpticDisc od(Coordinate<int> (6,7),8); std::cout << od.toString(); }
int DateTime::compare(const DateTime& other) const { if (now_ && other.now_) { return 0; } else { Date d(*this), od(other); Time t(*this), ot(other); if (int x = d.compare(od)) { return x; } else { return t.compare(ot); } } }
void Viewer::parseCommandLine( int & argc, char ** argv ) { boost::program_options::options_description od("Usage: Viewer"); od.add_options() ( "backdrop", boost::program_options::value<bool>()->default_value(true), "true|false" ) ( "cullingengine", boost::program_options::value<std::string>()->default_value("auto"), "auto|cpu|cuda|gl_compute") ( "file", boost::program_options::value<std::string>()->default_value(""), "file to load" ) ( "height", boost::program_options::value<int>()->default_value(0), "Application height" ) ( "renderengine", boost::program_options::value<std::string>()->default_value("Bindless"), "choose a renderengine from this list: VBO|VAB|VBOVAO|Bindless|BindlessVAO|DisplayList" ) ( "script", boost::program_options::value<std::string>()->default_value(""), "script to run" ) ( "shadermanager", boost::program_options::value<std::string>()->default_value("rix:ubo140"), "rixfx:uniform|rixfx:ubo140|rixfx:ssbo140|rixfx:shaderbufferload" ) ( "tonemapper", boost::program_options::value<bool>()->default_value(false), "true|false" ) ( "transparency", boost::program_options::value<std::string>()->default_value("OITClosestList"), "OITAll|OITClosestArray|OITClosestList|SB" ) ( "width", boost::program_options::value<int>()->default_value(0), "Application width" ) ; try { boost::program_options::variables_map opts; boost::program_options::store( boost::program_options::parse_command_line( argc, argv, od ), opts ); boost::program_options::notify( opts ); if ( !opts["help"].empty() ) { std::cout << od << std::endl; } m_tonemapperEnabled = opts["tonemapper"].as<bool>(); m_backdropEnabled = opts["backdrop"].as<bool>(); // Force to false when --raytracing true to not do it twice since the miss program renders the environment anyway. m_cullingMode = determineCullingMode( opts["cullingengine"].as<std::string>() ); m_startupFile = opts["file"].as<std::string>().c_str(); m_height = opts["height"].as<int>(); m_renderEngine = opts["renderengine"].as<std::string>(); m_runScript = opts["script"].as<std::string>().c_str(); m_shaderManagerType = determineShaderManagerType( opts["shadermanager"].as<std::string>() ); m_transparencyMode = determineTransparencyMode( opts["transparency"].as<std::string>() ); m_width = opts["width"].as<int>(); } catch ( boost::program_options::unknown_option e ) { std::cerr << "Unknown option: " << e.get_option_name() << ". "; std::cout << od << std::endl; } }
void MSDevice_Vehroutes::generateOutput() const { OutputDevice& routeOut = OutputDevice::getDeviceByOption("vehroute-output"); OutputDevice_String od(routeOut.isBinary(), 1); od.openTag(SUMO_TAG_VEHICLE).writeAttr(SUMO_ATTR_ID, myHolder.getID()); if (myHolder.getVehicleType().getID() != DEFAULT_VTYPE_ID) { od.writeAttr(SUMO_ATTR_TYPE, myHolder.getVehicleType().getID()); } od.writeAttr(SUMO_ATTR_DEPART, time2string(myHolder.getDeparture())); if (myHolder.hasArrived()) { od.writeAttr("arrival", time2string(MSNet::getInstance()->getCurrentTimeStep())); } if (myWithTaz) { od.writeAttr(SUMO_ATTR_FROM_TAZ, myHolder.getParameter().fromTaz).writeAttr(SUMO_ATTR_TO_TAZ, myHolder.getParameter().toTaz); } if (myReplacedRoutes.size() > 0) { od.openTag(SUMO_TAG_ROUTE_DISTRIBUTION); for (unsigned int i = 0; i < myReplacedRoutes.size(); ++i) { writeXMLRoute(od, i); } } writeXMLRoute(od); if (myReplacedRoutes.size() > 0) { od.closeTag(); } od.closeTag(); od.lf(); if (mySorted) { myRouteInfos[myHolder.getDeparture()] += od.getString(); myDepartureCounts[myHolder.getDeparture()]--; std::map<const SUMOTime, int>::iterator it = myDepartureCounts.begin(); while (it != myDepartureCounts.end() && it->second == 0) { routeOut << myRouteInfos[it->first]; myRouteInfos.erase(it->first); myDepartureCounts.erase(it); it = myDepartureCounts.begin(); } } else { routeOut << od.getString(); } }
void _ParseArgs(int argc, char* argv[]) { namespace po = boost::program_options; po::options_description od("Allowed options"); od.add_options() ("stat", po::value<bool>()->default_value(true), "Generate stat") ("plot", po::value<bool>()->default_value(true), "Generate plot") ("partial_load", po::value<size_t>()->default_value(0), "Load partial reviews. Unlimited when 0.") ("help", "show help message") ; po::variables_map vm; po::store(po::command_line_parser(argc, argv).options(od).run(), vm); po::notify(vm); if (vm.count("help") > 0) { // well... this doesn't show boolean as string. cout << std::boolalpha; cout << od << "\n"; exit(0); } stat = vm["stat"].as<bool>(); plot = vm["plot"].as<bool>(); partial_load = vm["partial_load"].as<size_t>(); stringstream ss; ss << std::boolalpha; ss << "stat=" << stat << "\n"; ss << "plot=" << plot << "\n"; ss << "partial_load=" << partial_load << "\n"; ss << "fn_tweets=" << fn_tweets << "\n"; ss << "fn_result=" << fn_result << "\n"; ss << "fn_plot=" << fn_plot << "\n"; ss << "cluster_granularity_longi=" << cluster_granularity_longi << "\n"; ss << "cluster_granularity_lati=" << cluster_granularity_lati << "\n"; _desc = ss.str(); cout << "Conf:\n"; cout << Util::Indent(_desc, 2); }
void _ParseArgs(int argc, char* argv[]) { po::options_description od("Allowed options"); od.add_options() //("time_interval_granularity", // po::value<double>()->default_value(Conf::GetStr("time_interval_granularity"))) ("out_dir", po::value<string>()->default_value(Conf::GetStr("out_dir"))) ("help", "show help message") ; po::variables_map vm; po::store(po::command_line_parser(argc, argv).options(od).run(), vm); po::notify(vm); if (vm.count("help") > 0) { // well... this doesn't show boolean as string. cout << std::boolalpha; cout << od << "\n"; exit(0); } __EditYaml<string>("out_dir", vm); // Print all parameters Cons::P("Options:"); YAML::Node n = _yaml_root; for (YAML::const_iterator it = n.begin(); it != n.end(); ++ it) { string k = it->first.as<string>(); if (it->second.IsScalar()) { Cons::P(boost::format(" %s: %s") % k % it->second.as<string>()); // it->second.Type() } else { THROW("Implement"); } } //for (const auto o: vm) { // Cons::P(boost::format(" %s=%s") % o.first % o.second.as<string>()); //} }
void CPmwMDIChild::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd) { CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd); #if 1 od("OnMDIActivate: %d (act:%lx [%x], deact:%lx, this:%lx), Act:%lx [%x]\r\n", bActivate, pActivateWnd, (WORD)pActivateWnd->GetSafeHwnd(), pDeactivateWnd, this, GetActiveView(), (WORD)GetActiveView()->GetSafeHwnd()); #endif // Tell the main window we have a view (or not) CWnd *pWnd = AfxGetMainWnd (); if ((bActivate == FALSE) && (pActivateWnd == NULL)) pWnd->PostMessage (WM_VIEWSCHANGED, FALSE, 0); else pWnd->PostMessage (WM_VIEWSCHANGED, TRUE, 0); }
void PFMatrixConvertWorker::registerProto() { QList<PortDescriptor*> p; QList<Attribute*> a; QMap<Descriptor, DataTypePtr> m; Descriptor id(FMATRIX_IN_PORT_ID, PFMatrixConvertWorker::tr("Frequency matrix"), PFMatrixConvertWorker::tr("Frequency matrix to convert.")); m[PFMatrixWorkerFactory::FMATRIX_SLOT] = PFMatrixWorkerFactory::FREQUENCY_MATRIX_MODEL_TYPE(); DataTypePtr t(new MapDataType(Descriptor("convert.pfmatrix.content"), m)); Descriptor od(WMATRIX_OUT_PORT_ID, PFMatrixConvertWorker::tr("Weight matrix"), PFMatrixConvertWorker::tr("Produced statistical model of specified TFBS data.")); p << new PortDescriptor(id, t, true /*input*/); QMap<Descriptor, DataTypePtr> outM; outM[PWMatrixWorkerFactory::WMATRIX_SLOT] = PWMatrixWorkerFactory::WEIGHT_MATRIX_MODEL_TYPE(); p << new PortDescriptor(od, DataTypePtr(new MapDataType("fmatrix.convert.out", outM)), false /*input*/, true /*multi*/); { Descriptor ad(ALG_ATTR, PWMatrixBuildWorker::tr("Weight algorithm"), PWMatrixBuildWorker::tr("Different weight algorithms uses different functions to build weight matrices. It allows us to get better precision on different data sets. Log-odds, NLG and Match algorithms are sensitive to input matrices with zero values, so some of them may not work on those matrices.")); a << new Attribute(ad, BaseTypes::STRING_TYPE(), true, BuiltInPWMConversionAlgorithms::BVH_ALGO); } { Descriptor td(TYPE_ATTR, PWMatrixBuildWorker::tr("Matrix type"), PWMatrixBuildWorker::tr("Dinucleic matrices are more detailed, while mononucleic one are more useful for small input data sets.")); a << new Attribute(td, BaseTypes::BOOL_TYPE(), true, false /* false = mononucleic, true = dinucleic */); } Descriptor desc(ACTOR_ID, tr("Convert Frequency Matrix"), tr("Converts frequency matrix to weight matrix. Weight matrices are used for probabilistic recognition of transcription factor binding sites.")); ActorPrototype* proto = new IntegralBusActorPrototype(desc, p, a); QMap<QString, PropertyDelegate*> delegates; { QVariantMap modeMap; QStringList algo = AppContext::getPWMConversionAlgorithmRegistry()->getAlgorithmIds(); foreach (QString curr, algo) { modeMap[curr] = QVariant(curr); } delegates[ALG_ATTR] = new ComboBoxDelegate(modeMap); }
bool keysig_search_ascii_stupid(uint8_t *cipher, keysig_notify_fn_t notify, void *user) { keysig_search_init(); memcpy(g_cipher, cipher, 8); g_notify = notify; g_user = user; #if 1 return search_stupid(4, 4) || search_stupid(3, 5) || search_stupid(5, 3) || search_stupid(2, 6) || search_stupid(6, 2) || search_stupid(1, 7) || search_stupid(7, 1) || search_stupid(0, 8) || search_stupid(8, 0); #else #define do(i) for(int a##i = 0; a##i < sizeof(hex_digits); a##i++) { g_key[i] = hex_digits[a##i]; #define od() } do(0)do(1)do(2)do(3)do(4)do(5)do(6)do(7) if(check_stupid()) return true; od()od()od()od()od()od()od()od() #undef do #undef od return false; #endif }
void PFMatrixBuildWorker::registerProto() { QList<PortDescriptor*> p; QList<Attribute*> a; QMap<Descriptor, DataTypePtr> m; Descriptor id(BasePorts::IN_MSA_PORT_ID(), PFMatrixBuildWorker::tr("Input alignment"), PFMatrixBuildWorker::tr("Input multiple sequence alignment for building statistical model.")); m[BaseSlots::MULTIPLE_ALIGNMENT_SLOT()] = BaseTypes::MULTIPLE_ALIGNMENT_TYPE(); DataTypePtr t(new MapDataType(Descriptor("build.pfmatrix.content"), m)); Descriptor od(FMATRIX_OUT_PORT_ID, PFMatrixBuildWorker::tr("Frequency matrix"), PFMatrixBuildWorker::tr("Produced statistical model of specified TFBS data.")); p << new PortDescriptor(id, t, true /*input*/); QMap<Descriptor, DataTypePtr> outM; outM[PFMatrixWorkerFactory::FMATRIX_SLOT] = PFMatrixWorkerFactory::FREQUENCY_MATRIX_MODEL_TYPE(); p << new PortDescriptor(od, DataTypePtr(new MapDataType("fmatrix.build.out", outM)), false /*input*/, true /*multi*/); { Descriptor td(TYPE_ATTR, PWMatrixBuildWorker::tr("Matrix type"), PWMatrixBuildWorker::tr("Dinucleic matrices are more detailed, while mononucleic one are more useful for small input data sets.")); a << new Attribute(td, BaseTypes::BOOL_TYPE(), true, false /* false = mononucleic, true = dinucleic */); } Descriptor desc(ACTOR_ID, tr("Build Frequency Matrix"), tr("Builds frequency matrix. Frequency matrices are used for probabilistic recognition of transcription factor binding sites.")); ActorPrototype* proto = new IntegralBusActorPrototype(desc, p, a); QMap<QString, PropertyDelegate*> delegates; { QVariantMap modeMap; modeMap[tr("Mononucleic")] = QVariant(false); modeMap[tr("Dinucleic")] = QVariant(true); delegates[TYPE_ATTR] = new ComboBoxDelegate(modeMap); } proto->setPrompter(new PFMatrixBuildPrompter()); proto->setEditor(new DelegateEditor(delegates)); proto->setIconPath(":weight_matrix/images/weight_matrix.png"); WorkflowEnv::getProtoRegistry()->registerProto(BaseActorCategories::CATEGORY_TRANSCRIPTION(), proto); }
void director::start (base::conf_node& conf, const boost::filesystem::path& home_path) { m_config = &conf; m_filemgr.start (conf.child ("file_manager"), home_path); for (auto i = m_outdir.begin(); i != m_outdir.end(); ++i) { std::unique_ptr<output_director> od (i->second->create_output_director()); od->defaults(m_config->child (i->first)); } register_config(); m_info.sample_rate = conf.child ("sample_rate").get<int> (); m_info.num_channels = conf.child ("num_channels").get<int> (); m_info.block_size = conf.child ("block_size").get<int> (); m_world = new world (m_info); m_world->set_patcher (base::manage (new patcher_dynamic)); start_output (); }
int main(int argc, char *argv[]) { // initialize GLUT, set window size and display mode, create the main window glutInit( &argc, argv ); glutSetOption( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION ); options::options_description od("Usage: GLUTMinimal"); od.add_options() ( "filename", options::value<std::string>()->default_value("cubes"), "file to load" ) ( "effectlibrary", options::value<std::string>(), "effectlibrary to load for replacements" ) ( "replace", options::value< std::vector<std::string> >()->composing()->multitoken(), "file to load" ) ( "stereo", "enable stereo" ) //always on ( "continuous", "enable continuous rendering" ) ( "headlight", "add a headlight to the camera" ) ( "statistics", "show statistics of scene" ) ( "combineVertexAttributes", "combine all vertexattribute into a single buffer" ) ( "frames", options::value<int>()->default_value(-1), "benchmark a specific number of frames. The exit code returns the frames per second." ) ( "duration", options::value<double>()->default_value(0.0), "benchmark for a specific duration. The exit code returns the frames per second." ) ( "renderengine", options::value<std::string>()->default_value("Bindless"), "choose a renderengine from this list: VBO|VAB|VBOVAO|Bindless|BindlessVAO|DisplayList" ) ( "shadermanager", options::value<std::string>()->default_value("rixfx:shaderbufferload"), "rixfx:uniform|rixfx:ubo140|rixfx:ssbo140|rixfx:shaderbufferload" ) ( "cullingengine", options::value<std::string>()->default_value("cpu"), "auto|cpu|cuda|gl_compute") ( "culling", options::value<bool>()->default_value(true), "enable/disable culling") ( "autoclipplanes", options::value<bool>()->default_value(true), "enable/disable autoclipplane") ( "help", "show help") ; #if 0 // not yet implemented std::cout << "During execution hit 's' for screenshot and 'x' to toggle stereo" << std::endl; std::cout << "Stereo screenshots will be saved as side/side png with filename 'stereo.pns'." << std::endl; std::cout << "They can be viewed with the 3D Vision Photo Viewer." << std::endl; #endif int result = -1; try { options::variables_map opts; options::store( options::parse_command_line( argc, argv, od ), opts ); if ( dp::util::fileExists( "GLUTMinimal.cfg" ) ) { options::store( options::parse_config_file<char>( "GLUTMinimal.cfg", od), opts); } options::notify( opts ); if ( !opts["help"].empty() ) { std::cout << od << std::endl; } result = runApp( opts ); } catch ( options::unknown_option e ) { std::cerr << "Unknown option: " << e.get_option_name() << ". "; std::cout << od << std::endl; std::cerr << "Press enter to continue." << std::endl; std::string line; getline( std::cin, line ); } return result; }
OptionalDouble AirGap_Impl::solarReflectance() const { OptionalDouble od(0.0); return od; }
double AirGap_Impl::solarAbsorptance() const { OptionalDouble od(0.0); return *od; }
OptionalDouble AirGap_Impl::thermalReflectance() const { OptionalDouble od(0.0); return od; }
bool MeasurementFunctorNVPM::option( const vector<string>& optionString ) { options::options_description od("Usage: DPTApp"); od.add_options() ( "counterFilter", options::value< std::vector<std::string> >()->composing()->multitoken(), "tests to run" ) ( "resultsDir", options::value<std::string>(), "Directory to dump the results to" ) ( "resultsFilenamePrefix", options::value<std::string>(), "Prefix to add to the result output file" ) ( "resultsFilenameSuffix", options::value<std::string>(), "Suffix to add to the result output file" ) ; options::basic_parsed_options<char> parsedOpts = options::basic_command_line_parser<char>( optionString ).options( od ).allow_unregistered().run(); options::variables_map optsMap; options::store( parsedOpts, optsMap ); // Counter Filter if( optsMap["counterFilter"].empty() ) { std::cerr << "Warning: no counter filter was specified. All counters will be recorded for this run.\n"; } else if( !optsMap.count("counterFilter") ) { std::cerr << "Warning: one or more filters must follow the --counterFilter flag. All counters will be recorded for this run.\n"; } else { m_counterFilters = optsMap["counterFilter"].as< std::vector<std::string> >(); } // Results Dir if( optsMap["resultsDir"].empty() ) { std::cerr << "Warning: No result directory was specified\n"; } else { m_resultsDir = optsMap["resultsDir"].as<std::string>(); } if ( !dp::util::directoryExists( m_resultsDir ) ) { if ( ! dp::util::createDirectory( m_resultsDir ) ) { std::cerr << "Unable to create directory <" << m_resultsDir << ">\n"; return( false ); } } // Result Filename Prefix if( optsMap["resultsFilenamePrefix"].empty() ) { std::cerr << "No result filename prefix was specified. A filename prefix won't be used for this run\n"; } else { std::string prefix( optsMap["resultsFilenamePrefix"].as<std::string>() ); m_resultsFilenamePrefix = prefix; } // Result Filename Suffix if( optsMap["resultsFilenameSuffix"].empty() ) { std::cerr << "No result filename suffix was specified. A filename suffix won't be used for this run\n"; } else { std::string suffix( optsMap["resultsFilenameSuffix"].as<std::string>() ); m_resultsFilenamePrefix = suffix; } return true; }
OptionalDouble GasLayer_Impl::getVisibleTransmittance() const { OptionalDouble od(1.0); return od; }
SgRdrBackend::SgRdrBackend( const std::string& rendererName , const std::vector<std::string>& options ) { // Initialize freeglut char* dummyChar[] = {"nothing"}; int dummyInt = 0; glutInit(&dummyInt, nullptr); // Parse options options::options_description od("Usage: DPTApp"); od.add_options() ( "renderengine", options::value<std::string>(), "The renderengine to use" ) ( "shadermanager", options::value<std::string>(), "The shader manager to use" ) ( "cullingengine", options::value<std::string>(), "The culling engine to use" ) ; options::basic_parsed_options<char> parsedOpts = options::basic_command_line_parser<char>( options ).options( od ).allow_unregistered().run(); options::variables_map optsMap; options::store( parsedOpts, optsMap ); std::string renderEngine = optsMap["renderengine"].as<std::string>(); std::string cullingEngine = optsMap["cullingengine"].as<std::string>(); std::string shaderManager = optsMap["shadermanager"].as<std::string>(); bool disableCulling = false; // Create the renderer as specified dp::culling::Mode cullingMode = dp::culling::Mode::AUTO; if ( cullingEngine == "cpu" ) { cullingMode = dp::culling::Mode::CPU; } else if ( cullingEngine == "gl_compute" ) { cullingMode = dp::culling::Mode::OPENGL_COMPUTE; } else if ( cullingEngine == "cuda" ) { cullingMode = dp::culling::Mode::CUDA; } else if ( cullingEngine == "none" ) { disableCulling = true; } else if ( cullingEngine != "auto" ) { std::cerr << "unknown culling engine, turning culling off" << std::endl; disableCulling = true; } dp::fx::Manager smt = getShaderManager( shaderManager ); //The chosen renderer takes precedence over the chosen shader manager. if( rendererName == "RiXGL.rdr" ) { m_renderer = dp::sg::renderer::rix::gl::SceneRenderer::create ( renderEngine.c_str() , smt , cullingMode ); } else { DP_ASSERT(!"Unknown Renderer"); } m_renderer->setCullingEnabled( !disableCulling ); }
void VarDriverXY::preProcessMetObs() { vector<real> rhoP; // Check the data directory for files QDir dataPath("./vardata"); dataPath.setFilter(QDir::Files); dataPath.setSorting(QDir::Name); QStringList filenames = dataPath.entryList(); int processedFiles = 0; QList<MetObs>* metData = new QList<MetObs>; cout << "Found " << filenames.size() << " data files to read..." << endl; for (int i = 0; i < filenames.size(); ++i) { metData->clear(); QString file = filenames.at(i); QStringList fileparts = file.split("."); if (fileparts.isEmpty()) { cout << "Unknown file! " << file.toAscii().data() << endl; continue; } QString suffix = fileparts.last(); QString prefix = fileparts.first(); if (prefix == "swp") { // Switch it to suffix suffix = "swp"; } cout << "Processing " << file.toAscii().data() << " of type " << suffix.toAscii().data() << endl; QFile metFile(dataPath.filePath(file)); // Read different types of files switch (dataSuffix.value(suffix)) { case (frd): if (!read_frd(metFile, metData)) cout << "Error reading frd file" << endl; break; case (cls): if (!read_cls(metFile, metData)) cout << "Error reading frd file" << endl; break; case (sec): if (!read_sec(metFile, metData)) cout << "Error reading min file" << endl; break; case (ten): if (!read_ten(metFile, metData)) cout << "Error reading ten file" << endl; break; case (swp): if (!read_dorade(metFile, metData)) cout << "Error reading swp file" << endl; break; case (sfmr): if (!read_sfmr(metFile, metData)) cout << "Error reading sfmr file" << endl; break; case (wwind): if (!read_wwind(metFile, metData)) cout << "Error reading wwind file" << endl; break; case (qscat): if (!read_qscat(metFile, metData)) cout << "Error reading wwind file" << endl; break; case (ascat): if (!read_ascat(metFile, metData)) cout << "Error reading wwind file" << endl; break; case (nopp): if (!read_nopp(metFile, metData)) cout << "Error reading wwind file" << endl; break; case (cen): continue; default: cout << "Unknown data type, skipping..." << endl; continue; } processedFiles++; // Process the metObs into Observations QDateTime startTime = frameVector.front().getTime(); QDateTime endTime = frameVector.back().getTime(); for (int i = 0; i < metData->size(); ++i) { // Make sure the ob is within the time limits MetObs metOb = metData->at(i); QDateTime obTime = metOb.getTime(); QString obstring = obTime.toString(Qt::ISODate); QString tcstart = startTime.toString(Qt::ISODate); QString tcend = endTime.toString(Qt::ISODate); if ((obTime < startTime) or (obTime > endTime)) continue; int tci = startTime.secsTo(obTime); if ((tci < 0) or (tci > (int)frameVector.size())) { cout << "Time problem with observation " << tci << endl; continue; } // Our generic observation Observation varOb; // Get the X, Y & Z double latrad = frameVector[tci].getLat() * Pi/180.0; double fac_lat = 111.13209 - 0.56605 * cos(2.0 * latrad) + 0.00012 * cos(4.0 * latrad) - 0.000002 * cos(6.0 * latrad); double fac_lon = 111.41513 * cos(latrad) - 0.09455 * cos(3.0 * latrad) + 0.00012 * cos(5.0 * latrad); double obY = (metOb.getLat() - frameVector[tci].getLat())*fac_lat; double obX = (metOb.getLon() - frameVector[tci].getLon())*fac_lon; double height = metOb.getAltitude(); // Make sure the ob is in the domain if ((obX < x.front()) or (obX > x.back()) or (obY < y.front()) or (obY > y.back()) or (abs(height - zLevel) > 50)) continue; varOb.setCartesianX(obX); varOb.setCartesianY(obY); real Um = frameVector[tci].getUmean(); real Vm = frameVector[tci].getVmean(); varOb.setAltitude(height); // Reference states real rhoBar = rhoBase*exp(-rhoInvScaleHeight*height); real qBar = 19.562 - 0.004066*height + 7.8168e-7*height*height; real hBar = 3.5e5; /* Use bilinear interpolation here too for now, eventually probably a spline real rhoaBG = bilinearField(obX, obY, 4)/100. + rhoBar; real qBG = bilinearField(obX, obY, 3) + qBar; real rhoBG = rhoaBG*(1+qBG/1000.); */ // Initialize the weights varOb.setWeight(0., 0); varOb.setWeight(0., 1); varOb.setWeight(0., 2); varOb.setWeight(0., 3); varOb.setWeight(0., 4); varOb.setWeight(0., 5); double u, v, w, rho, rhoa, qv, energy, rhov, rhou, rhow, wspd, vBG; // uBG not used in SFMR calculation switch (metOb.getObType()) { case (MetObs::dropsonde): varOb.setType(MetObs::dropsonde); u = metOb.getCartesianUwind(); v = metOb.getCartesianVwind(); w = metOb.getVerticalVelocity(); rho = metOb.getMoistDensity(); rhoa = metOb.getAirDensity(); qv = metOb.getQv(); energy = metOb.getMoistStaticEnergy(); // Separate obs for each measurement // rho v 1 m/s error if ((u != -999) and (rho != -999)) { varOb.setWeight(1., 0); rhov = rho*(v - Vm); varOb.setOb(rhov); varOb.setError(1.0); obVector.push_back(varOb); varOb.setWeight(0., 0); // rho u 1 m/s error varOb.setWeight(1., 1); rhou = rho*(u - Um); //cout << "RhoU: " << rhou << endl; varOb.setOb(rhou); varOb.setError(1.0); obVector.push_back(varOb); varOb.setWeight(0., 1); } if ((w != -999) and (rho != -999)) { // rho w 1.5 m/s error varOb.setWeight(1., 2); rhow = rho*w; varOb.setOb(rhow); varOb.setError(1.5); obVector.push_back(varOb); varOb.setWeight(0., 2); } if (energy != -999) { // energy 5 kJ error varOb.setWeight(1., 3); varOb.setOb((energy - hBar)*1.e-3); varOb.setError(5.0); obVector.push_back(varOb); varOb.setWeight(0., 3); } if (qv != -999) { // Qv 2 g/kg error varOb.setWeight(1., 4); varOb.setOb(qv-qBar); varOb.setError(2.0); obVector.push_back(varOb); varOb.setWeight(0., 4); } if (rhoa != -999) { // Rho prime .1 kg/m^3 error varOb.setWeight(1., 5); varOb.setOb((rhoa-rhoBar)*100); varOb.setError(1.0); obVector.push_back(varOb); varOb.setWeight(0., 5); } break; case (MetObs::flightlevel): varOb.setType(MetObs::flightlevel); u = metOb.getCartesianUwind(); v = metOb.getCartesianVwind(); w = metOb.getVerticalVelocity(); rho = metOb.getMoistDensity(); rhoa = metOb.getAirDensity(); qv = metOb.getQv(); energy = metOb.getMoistStaticEnergy(); // Separate obs for each measurement // rho v 1 m/s error if ((u != -999) and (rho != -999)) { varOb.setWeight(1., 0); rhov = rho*(v - Vm); varOb.setOb(rhov); varOb.setError(1.0); obVector.push_back(varOb); varOb.setWeight(0., 0); // rho u 1 m/s error varOb.setWeight(1., 1); rhou = rho*(u - Um); varOb.setOb(rhou); varOb.setError(1.0); obVector.push_back(varOb); varOb.setWeight(0., 1); } if ((w != -999) and (rho != -999)) { // rho w 1 dm/s error varOb.setWeight(1., 2); rhow = rho*w; varOb.setOb(rhow); varOb.setError(0.25); obVector.push_back(varOb); varOb.setWeight(0., 2); } if (energy != -999) { // energy 5 kJ error varOb.setWeight(1., 3); varOb.setOb((energy - hBar)*1.e-3); varOb.setError(5.0); obVector.push_back(varOb); varOb.setWeight(0., 3); } if (qv != -999) { // Qv 2 g/kg error varOb.setWeight(1., 4); varOb.setOb(qv-qBar); varOb.setError(2.0); obVector.push_back(varOb); varOb.setWeight(0., 4); } if (rhoa != -999) { // Rho prime .1 kg/m^3 error varOb.setWeight(1., 5); varOb.setOb((rhoa-rhoBar)*100); varOb.setError(1.0); obVector.push_back(varOb); varOb.setWeight(0., 5); } break; case (MetObs::sfmr): varOb.setType(MetObs::sfmr); wspd = metOb.getWindSpeed(); // This needs to be redone for the Cartesian case vBG = 1.e3*bilinearField(obX, obY, 0); //uBG = -1.e5*bilinearField(obX, 20., 1)/(rad*20.); varOb.setWeight(1., 0); //varOb.setWeight(1., 1); varOb.setOb(wspd); varOb.setError(10.0); obVector.push_back(varOb); break; case (MetObs::qscat): varOb.setType(MetObs::qscat); u = metOb.getCartesianUwind(); v = metOb.getCartesianVwind(); if (u != -999) { varOb.setWeight(1., 0); // Multiply by rho later from grid values rhov = (v - Vm); varOb.setOb(rhov); varOb.setError(2.5); obVector.push_back(varOb); varOb.setWeight(0., 0); // rho u 1 m/s error varOb.setWeight(1., 1); rhou = (u - Um); //cout << "RhoU: " << rhou << endl; varOb.setOb(rhou); varOb.setError(2.5); obVector.push_back(varOb); varOb.setWeight(0., 1); } break; case (MetObs::ascat): varOb.setType(MetObs::ascat); u = metOb.getCartesianUwind(); v = metOb.getCartesianVwind(); if (u != -999) { varOb.setWeight(1., 0); // Multiply by rho later from grid values rhov = (v - Vm); varOb.setOb(rhov); varOb.setError(2.5); obVector.push_back(varOb); varOb.setWeight(0., 0); // rho u 1 m/s error varOb.setWeight(1., 1); rhou = (u - Um); //cout << "RhoU: " << rhou << endl; varOb.setOb(rhou); varOb.setError(2.5); obVector.push_back(varOb); varOb.setWeight(0., 1); } break; case (MetObs::radar): varOb.setType(MetObs::radar); // Geometry terms double az = metOb.getAzimuth()*Pi/180.; double el = metOb.getElevation()*Pi/180.; double uWgt = sin(az)*cos(el); double vWgt = cos(az)*cos(el); double wWgt = sin(el); // Fall speed double Z = metOb.getReflectivity(); double H = metOb.getAltitude(); double ZZ=pow(10.0,(Z*0.1)); double hlow= 5600 - 1000 * .5; double hhi= hlow + 1000; /* density correction term (rhoo/rho)*0.45 [rho(Z)=rho_o exp-(z/H), where H is the scale height = 9.58125 from Gray's inner 2 deg composite] 0.45 density correction from Beard (1985, JOAT pp 468-471) Adjusted to use dunion_mt hydrostatic scale height -MB */ double DCOR=exp(0.45*metOb.getAltitude()*0.0001068); // The snow relationship (Atlas et al., 1973) --- VT=0.817*Z**0.063 (m/s) double VTS=-DCOR * (0.817*pow(ZZ,(double)0.063)); // The rain relationship (Joss and Waldvogel,1971) --- VT=2.6*Z**.107 (m/s) */ double VTR=-DCOR * (2.6*pow(ZZ,(double).107)); /* Test if height is in the transition region between SNOW and RAIN defined as hlow in km < H < hhi in km if in the transition region do a linear weight of VTR and VTS */ if ((Z > 20) and (Z <= 30)) { double WEIGHTR=(Z-20)/(10); double WEIGHTS=1.-WEIGHTR; VTS=(VTR*WEIGHTR+VTS*WEIGHTS)/(WEIGHTR+WEIGHTS); } else if (Z > 30) { VTS=VTR; } double w_term=VTR*(hhi-H)/1000 + VTS*(H-hlow)/1000; if (H < hlow) w_term=VTR; if (H > hhi) w_term=VTS; double Vdopp = metOb.getRadialVelocity() - w_term*sin(el) - Um*sin(az)*cos(el) - Vm*cos(az)*cos(el); varOb.setWeight(vWgt, 0); varOb.setWeight(uWgt, 1); varOb.setWeight(wWgt, 2); // Theoretically, rhoPrime could be included as a prognostic variable here... // However, adding another unknown without an extra equation makes the problem even more underdetermined // so assume it is small and ignore it // double rhopWgt = -Vdopp; //varOb.setWeight(rhopWgt, 5); // Set the error according to the spectrum width and potential fall speed error (assume 2 m/s?) double DopplerError = metOb.getSpectrumWidth() + fabs(wWgt)*2.; if (DopplerError < 1.0) DopplerError = 1.0; varOb.setError(DopplerError); varOb.setOb(Vdopp); obVector.push_back(varOb); break; } } cout << obVector.size() << " total observations." << endl; } delete metData; // Write the Obs to a summary text file ofstream obstream("Observations.in"); // Header messes up reload /*ostream_iterator<string> os(obstream, "\t "); *os++ = "Type"; *os++ = "r"; *os++ = "z"; *os++ = "NULL"; *os++ = "Observation"; *os++ = "Inverse Error"; *os++ = "Weight 1"; *os++ = "Weight 2"; *os++ = "Weight 3"; *os++ = "Weight 4"; *os++ = "Weight 5"; *os++ = "Weight 6"; obstream << endl; */ ostream_iterator<double> od(obstream, "\t "); for (unsigned int i=0; i < obVector.size(); i++) { Observation ob = obVector.at(i); *od++ = ob.getType(); *od++ = ob.getCartesianX(); *od++ = ob.getCartesianY(); // NULL 3rd dimension *od++ = -999.; *od++ = ob.getOb(); *od++ = ob.getInverseError(); for (unsigned int var = 0; var < numVars; var++) *od++ = ob.getWeight(var); obstream << endl; } // Load the observations into a vector obs = new real[obVector.size()*12]; for (unsigned int m=0; m < obVector.size(); m++) { int n = m*12; Observation ob = obVector.at(m); obs[n] = ob.getOb(); obs[n+1] = ob.getInverseError(); for (unsigned int var = 0; var < numVars; var++) { obs[n+2+var] = ob.getWeight(var); } obs[n+2+numVars] = ob.getCartesianX(); obs[n+3+numVars] = ob.getCartesianY(); obs[n+4+numVars] = ob.getAltitude(); obs[n+5+numVars] = ob.getType(); } // All done preprocessing if (!processedFiles) { cout << "No files processed, nothing to do :(" << endl; // return 0; } else { cout << "Finished preprocessing " << processedFiles << " files." << endl; } }
int main(){ // double r=2.0; // double i=3.0; Zespolone a=zes(20.0,32.0); Zespolone b=zes(4.0,4.0); dod2(&a,&b); printz(b); b=zes(4.0,4.0); a=zes(20.0,32.0); printz(*dod(a,b)); od2(&a,&b); printz(b); b=zes(4.0,4.0); a=zes(20.0,32.0); printz(*od(a,b)); mn2(&a,&b); printz(b); b=zes(4.0,4.0); a=zes(20.0,32.0); printz(*mn(a,b)); dziel2(&a,&b); printz(b); b=zes(4.0,4.0); a=zes(20.0,32.0); printz(*dziel(a,b)); return 0;}