void ItemHandle::doLaunch(bool useXdgOpen, const char* globalExe, const char* globalArgs) { preLaunchCheck(); UserCore::Item::Misc::ExeInfoI* ei = getItemInfo()->getActiveExe(); gcString e(globalExe); gcString args; gcString ea(ei->getExeArgs()); gcString ua(ei->getUserArgs()); gcString ga(globalArgs); gcString wdp(ei->getExe()); if (!useXdgOpen) { //if we have a valid global exe need to append the local exe as the first arg if (e.size() > 0) args += gcString(ei->getExe()); else globalExe = ei->getExe(); } auto AppendArgs = [&args](const std::string& a) { if (a.size() == 0) return; if (args.size() > 0) args += " "; args += a; }; AppendArgs(ea); AppendArgs(ua); if (!useXdgOpen) AppendArgs(ga); bool res = false; if (useXdgOpen && args.size() != 0) Warning(gcString("Arguments '{1}' are not being passed to non-executable file '{0}'.", ei->getExe(), args)); UserCore::Item::BranchInfoI* branch = getItemInfo()->getCurrentBranch(); #ifdef NIX64 if (!useXdgOpen && branch && branch->is32Bit()) { #ifdef USE_BITTEST int testRet = system("desura_bittest"); if (testRet != 0) throw gcException(ERR_NO32LIBS); #else throw gcException(ERR_NOBITTEST); #endif } #endif gcString libPathA; gcString libPathB; gcString libPath; if (branch) { libPathA = gcString("{0}/{1}/{2}/lib", UTIL::OS::getAppDataPath(), branch->getItemId().getFolderPathExtension(), (uint32)branch->getBranchId()); libPathB = gcString("{0}/lib{1}", getItemInfo()->getPath(), branch->is32Bit()?"32":"64"); libPath = libPathA; if (UTIL::FS::isValidFolder(libPathB.c_str())) { libPath += ":"; libPath += libPathB; } } if (useXdgOpen) { res = UTIL::LIN::launchProcessXDG(ei->getExe(), libPath.c_str()); } else { if (libPathA.size() > 0) { std::vector<DesuraId> toolList; branch->getToolList(toolList); getUserCore()->getToolManager()->symLinkTools(toolList, libPathA.c_str()); } std::map<std::string, std::string> info; info["cla"] = args; info["lp"] = libPath; info["wd"] = UTIL::FS::PathWithFile(wdp.c_str()).getFolderPath(); res = UTIL::LIN::launchProcess(globalExe, info); } if (!res) { ERROR_OUTPUT(gcString("Failed to create {0} process. [{1}: {2}].\n", getItemInfo()->getName(), errno, ei->getExe()).c_str()); throw gcException(ERR_LAUNCH, errno, gcString("Failed to create {0} process. [{1}: {2}].\n", getItemInfo()->getName(), errno, ei->getExe())); } }
//---------------------------------------------------------------------------** // METHOD: ossimSensorModel::worldToLineSample() // // Performs forward projection of ground point to image space. // //---------------------------------------------------------------------------** void ossimH5GridModel::worldToLineSample(const ossimGpt& worldPoint, ossimDpt& ip) const { static const double PIXEL_THRESHOLD = .1; // acceptable pixel error static const int MAX_NUM_ITERATIONS = 20; if(worldPoint.isLatNan() || worldPoint.isLonNan()) { ip.makeNan(); return; } //--- // First check if the world point is inside bounding rectangle: //--- int iters = 0; ossimDpt wdp (worldPoint); if ( m_crossesDateline && (wdp.x < 0.0) ) { // Longitude points stored between 0 and 360. wdp.x += 360.0; } if( (m_boundGndPolygon.getNumberOfVertices() > 0) && (!m_boundGndPolygon.hasNans()) ) { if (!(m_boundGndPolygon.pointWithin(wdp))) { // if(theSeedFunction.valid()) // { // theSeedFunction->worldToLineSample(worldPoint, ip); // } // else if(!theExtrapolateGroundFlag) // if I am not already in the extrapolation routine // { // ip = extrapolate(worldPoint); // } ip.makeNan(); return; } } //--- // Substitute zero for null elevation if present: //--- double height = worldPoint.hgt; if ( ossim::isnan(height) ) { height = 0.0; } //--- // Utilize iterative scheme for arriving at image point. Begin with guess // at image center: //--- if(theSeedFunction.valid()) { theSeedFunction->worldToLineSample(worldPoint, ip); } else { ip.u = theRefImgPt.u; ip.v = theRefImgPt.v; } ossimDpt ip_du; ossimDpt ip_dv; ossimGpt gp, gp_du, gp_dv; double dlat_du, dlat_dv, dlon_du, dlon_dv; double delta_lat, delta_lon, delta_u, delta_v; double inverse_norm; bool done = false; //--- // Begin iterations: //--- do { //--- // establish perturbed image points about the guessed point: //--- ip_du.u = ip.u + 1.0; ip_du.v = ip.v; ip_dv.u = ip.u; ip_dv.v = ip.v + 1.0; //--- // Compute numerical partials at current guessed point: //--- lineSampleHeightToWorld(ip, height, gp); lineSampleHeightToWorld(ip_du, height, gp_du); lineSampleHeightToWorld(ip_dv, height, gp_dv); if(gp.isLatNan() || gp.isLonNan()) { gp = ossimCoarseGridModel::extrapolate(ip); } if(gp_du.isLatNan() || gp_du.isLonNan()) { gp_du = ossimCoarseGridModel::extrapolate(ip_du); } if(gp_dv.isLatNan() || gp_dv.isLonNan()) { gp_dv = ossimCoarseGridModel::extrapolate(ip_dv); } if ( m_crossesDateline ) { // Longitude set to between 0 and 360. if ( gp.lon < 0.0 ) gp.lon += 360.0; if ( gp_du.lon < 0.0 ) gp_du.lon += 360.0; if ( gp_dv.lon < 0.0 ) gp_dv.lon += 360.0; } dlat_du = gp_du.lat - gp.lat; //e dlon_du = gp_du.lon - gp.lon; //g dlat_dv = gp_dv.lat - gp.lat; //f dlon_dv = gp_dv.lon - gp.lon; //h //--- // Test for convergence: // Use the wdp as it was corrected if there was a date line cross. // delta_lat = wdp.lat - gp.lat; delta_lon = wdp.lon - gp.lon; // Compute linearized estimate of image point given gp delta: inverse_norm = dlat_dv*dlon_du - dlat_du*dlon_dv; // fg-eh if (!ossim::almostEqual(inverse_norm, 0.0, DBL_EPSILON)) { delta_u = (-dlon_dv*delta_lat + dlat_dv*delta_lon)/inverse_norm; delta_v = ( dlon_du*delta_lat - dlat_du*delta_lon)/inverse_norm; ip.u += delta_u; ip.v += delta_v; } else { delta_u = 0; delta_v = 0; } #if 0 cout << "gp: " << gp << "\ngp_du: " << gp_du << "\ngp_dv: " << gp_dv << "\ndelta_lat: " << delta_lat << "\ndelta_lon: " << delta_lon << "\ndelta_u: " << delta_u << "\ndelta_v: " << delta_v << endl; #endif done = ((fabs(delta_u) < PIXEL_THRESHOLD)&& (fabs(delta_v) < PIXEL_THRESHOLD)); ++iters; } while ( (!done) && (iters < MAX_NUM_ITERATIONS)); //--- // Note that this error mesage appears only if max count was reached while // iterating. A linear (no iteration) solution would finish with iters = // MAX_NUM_ITERATIONS + 1: //--- #if 0 /* please leave for debug: */ if (iters >= MAX_NUM_ITERATIONS) { std::cout << "MAX ITERATION!!!" << std::endl; std::cout << "delta_u = " << delta_u << "\ndelta_v = " << delta_v << "\n"; } else { std::cout << "ITERS === " << iters << std::endl; } std::cout << "iters = " << iters << "\n"; #endif //--- // The image point computed this way corresponds to full image space. // Apply image offset in the case this is a sub-image rectangle: //--- ip -= theSubImageOffset; } // End: worldToLineSample( ... )