ERMsg CEnvCanGribForecast::OpenDatasets(CCallback& callback) { ERMsg msg; StringVector filesList = GetFilesList(GetOutputFilePath("*"));//don't put extensionbea cause of the 2.5km trouble callback.PushTask("load gribs files (" + ToString(filesList.size()) + ")", filesList.size()); for (StringVector::const_iterator it = filesList.begin(); it != filesList.end() && msg; it++) { if (IsEqual(GetFileExtension(*it), ".grib2")) { size_t hhh = Gethhh(*it); ASSERT(hhh <= 52); size_t vv = GetVariable(*it); ASSERT(vv != NOT_INIT); msg += m_datasets[hhh][vv].OpenInputImage(*it); msg += callback.StepIt(); } } //msg += m_datasets[0][0].OpenInputImage("E:/Travaux/Install/DemoBioSIM/Update/EnvCan/Forecast/HRDPS/CMC_hrdps_continental_DPT_TGL_2_ps2.5km_2016050806_P000-00.grib2"); callback.PopTask(); if (msg) { m_geo2gribs.Set(PRJ_WGS_84, m_datasets[0][0].GetPrjID()); msg += m_geo2gribs.Create(); } return msg; }
// コマンドを実行する Hdc::Result hdcCmdFillLackData::Execute(const CString& strPath, const CString& strFileName, const CString& strTitle ) { Hdc::Result result = Hdc::rOk; hdcChart chart; CString strOutputPath, strSuffix; chart.SetSymbol( strTitle.Left(6) ); strOutputPath = GetOutputFilePath( strFileName, strSuffix ); result = chart.FillLackData( strPath, Period(), strOutputPath, SkipFirstRow() ); return result; }
ERMsg CEnvCanGribForecast::RemoveOldForecast(CCallback& callback) { ERMsg msg; StringVector filesList = GetFilesList(GetOutputFilePath("*"));//dont add extention because of the 2.5km callback.PushTask("Delete old gribs files", filesList.size()); for (StringVector::const_iterator it = filesList.begin(); it != filesList.end()&&msg; it++) { if (IsEqual(GetFileExtension(*it), ".grib2")) { ERMsg msgTemp = RemoveFile(*it); if (!msg) callback.AddMessage(msgTemp); msg += callback.StepIt(); } } callback.PopTask(); return msg; }
//**************************************************************************************************** ERMsg CEnvCanGribForecast::Execute(CCallback& callback) { ERMsg msg; //string outputPath = GetDir(WORKING_DIR); callback.AddMessage(GetString(IDS_UPDATE_DIR)); callback.AddMessage(m_workingDir, 1); callback.AddMessage(GetString(IDS_UPDATE_FROM)); callback.AddMessage(SERVER_NAME, 1); callback.AddMessage(""); //delete old files msg = RemoveOldForecast(callback); if (!msg) return msg; CInternetSessionPtr pSession; CHttpConnectionPtr pConnection; msg = GetHttpConnection(SERVER_NAME, pConnection, pSession); if (!msg) return msg; //size_t type = as<size_t>(TYPE); size_t delta_h = m_type == GT_HRDPS ? 1 : 3; callback.PushTask("Download gribs list", (MAX_FORECAST_HOURS / delta_h) ); StringVector fileList; //for (size_t HH = 0; HH < 24 && msg; HH+=6) size_t HH = GetLatestHH(pConnection); if (HH!=NOT_INIT) { for (size_t hhh = 0; hhh <= MAX_FORECAST_HOURS && msg; hhh += delta_h) { string remotePath = CEnvCanGribForecast::GetRemoteFilePath(HH, hhh, "*.grib2"); CFileInfoVector fileListTmp; msg = FindFiles(pConnection, remotePath, fileListTmp); //keep only some variables for (CFileInfoVector::iterator it = fileListTmp.begin(); it != fileListTmp.end(); it++) { string fileName = GetFileName(it->m_filePath); size_t hhh = Gethhh(fileName); size_t vv = GetVariable(fileName); if (hhh <= 48 && vv != NOT_INIT) fileList.push_back(it->m_filePath); } msg += callback.StepIt(); } } callback.PopTask(); callback.AddMessage("Number of gribs to download: " + ToString(fileList.size())); callback.PushTask("Download gribs (" + ToString(fileList.size()) +")", fileList.size()); int nbDownload = 0; for (size_t i = 0; i < fileList.size() && msg; i++) { string outputFilePath = GetOutputFilePath(GetFileName(fileList[i])); CreateMultipleDir(GetPath(outputFilePath)); msg = CopyFile(pConnection, fileList[i], outputFilePath.c_str(), INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_DONT_CACHE); if (msg) nbDownload++; msg += callback.StepIt(); } pConnection->Close(); pSession->Close(); callback.AddMessage("Number of gribs downloaded: " + ToString(nbDownload)); callback.PopTask(); return msg; }
ERMsg CUIEnvCanPrcpRadar::Execute(CCallback& callback) { ERMsg msg; string workingDir = GetDir(WORKING_DIR); CInternetSessionPtr pSession; CHttpConnectionPtr pConnection; msg = GetHttpConnection(SERVER_NAME, pConnection, pSession); if (!msg) return msg; callback.AddMessage(GetString(IDS_UPDATE_DIR)); callback.AddMessage(workingDir, 1); callback.AddMessage(GetString(IDS_UPDATE_FROM)); callback.AddMessage(SERVER_NAME, 1); callback.AddMessage(""); string type = as<size_t>(TYPE) == TYPE_06HOURS ? "06" : "24"; string path = SERVER_PATH + type + "/*.grib2"; CFileInfoVector fileList; msg = UtilWWW::FindFiles(pConnection, path, fileList); callback.AddMessage("Number of images found: " + ToString(fileList.size())); //keep only 10km grid for (CFileInfoVector::const_iterator it = fileList.begin(); it != fileList.end();) { // string fileTitle = GetFileTitle(it->m_filePath); // if (Find(fileTitle, "ps10km")) // { // it = fileList.erase(it); // } // else // { string fileName = GetFileName(it->m_filePath); string filePath = GetOutputFilePath(fileName); if (!NeedDownload(*it, filePath)) it = fileList.erase(it); else it++; //} msg += callback.StepIt(0); } //remove up to date file //for(int i=fileList.size()-1; i>=0; i--) //{ // string fileName = GetFileName(fileList[i].m_filePath); // string filePath = GetOutputFilePath(fileName); // if( !NeedDownload(fileList[i], filePath) ) // fileList.erase(fileList.begin() + i); // msg += callback.StepIt(0); //} callback.AddMessage("Number of images to download after clearing: " + ToString(fileList.size())); callback.PushTask("Download precipitation images + (" + ToString(fileList.size() )+ ")", fileList.size()); //callback.SetNbStep(fileList.size()); int nbDownload = 0; for (size_t i = 0; i < fileList.size() && msg; i++) { string filePath = GetOutputFilePath(GetFileName(fileList[i].m_filePath)); CreateMultipleDir(GetPath(filePath)); msg = UtilWWW::CopyFile(pConnection, fileList[i].m_filePath, filePath, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_DONT_CACHE); if (msg) nbDownload++; msg += callback.StepIt(); } pConnection->Close(); pSession->Close(); callback.AddMessage("Number of images downloaded: " + ToString(nbDownload)); callback.PopTask(); return msg; }
void My_TestGLDrawing::DrawTest(bool offscreen) { std::cout << "My_TestGLDrawing::DrawTest()\n"; HdPerfLog& perfLog = HdPerfLog::GetInstance(); perfLog.Enable(); // Reset all counters we care about. perfLog.ResetCache(HdTokens->extent); perfLog.ResetCache(HdTokens->points); perfLog.ResetCache(HdTokens->topology); perfLog.ResetCache(HdTokens->transform); perfLog.SetCounter(UsdImagingTokens->usdVaryingExtent, 0); perfLog.SetCounter(UsdImagingTokens->usdVaryingPrimvar, 0); perfLog.SetCounter(UsdImagingTokens->usdVaryingTopology, 0); perfLog.SetCounter(UsdImagingTokens->usdVaryingVisibility, 0); perfLog.SetCounter(UsdImagingTokens->usdVaryingXform, 0); int width = GetWidth(), height = GetHeight(); double aspectRatio = double(width)/height; GfFrustum frustum; frustum.SetPerspective(60.0, aspectRatio, 1, 100000.0); GfMatrix4d viewMatrix; viewMatrix.SetIdentity(); viewMatrix *= GfMatrix4d().SetRotate(GfRotation(GfVec3d(0, 1, 0), _rotate[0])); viewMatrix *= GfMatrix4d().SetRotate(GfRotation(GfVec3d(1, 0, 0), _rotate[1])); viewMatrix *= GfMatrix4d().SetTranslate(GfVec3d(_translate[0], _translate[1], _translate[2])); GfMatrix4d projMatrix = frustum.ComputeProjectionMatrix(); GfMatrix4d modelViewMatrix = viewMatrix; if (UsdGeomGetStageUpAxis(_stage) == UsdGeomTokens->z) { // rotate from z-up to y-up modelViewMatrix = GfMatrix4d().SetRotate(GfRotation(GfVec3d(1.0,0.0,0.0), -90.0)) * modelViewMatrix; } GfVec4d viewport(0, 0, width, height); _engine->SetCameraState(modelViewMatrix, projMatrix, viewport); size_t i = 0; TF_FOR_ALL(timeIt, GetTimes()) { UsdTimeCode time = *timeIt; if (*timeIt == -999) { time = UsdTimeCode::Default(); } UsdImagingGLRenderParams params; params.drawMode = GetDrawMode(); params.enableLighting = IsEnabledTestLighting(); params.enableIdRender = IsEnabledIdRender(); params.frame = time; params.complexity = _GetComplexity(); params.cullStyle = IsEnabledCullBackfaces() ? UsdImagingGLCullStyle::CULL_STYLE_BACK : UsdImagingGLCullStyle::CULL_STYLE_NOTHING; glViewport(0, 0, width, height); glEnable(GL_DEPTH_TEST); if(IsEnabledTestLighting()) { if(UsdImagingGLEngine::IsHydraEnabled()) { _engine->SetLightingState(_lightingContext); } else { _engine->SetLightingStateFromOpenGL(); } } if (!GetClipPlanes().empty()) { params.clipPlanes = GetClipPlanes(); for (size_t i=0; i<GetClipPlanes().size(); ++i) { glEnable(GL_CLIP_PLANE0 + i); } } GfVec4f const &clearColor = GetClearColor(); GLfloat clearDepth[1] = { 1.0f }; // Make sure we render to convergence. TfErrorMark mark; do { glClearBufferfv(GL_COLOR, 0, clearColor.data()); glClearBufferfv(GL_DEPTH, 0, clearDepth); _engine->Render(_stage->GetPseudoRoot(), params); } while (!_engine->IsConverged()); TF_VERIFY(mark.IsClean(), "Errors occurred while rendering!"); std::cout << "itemsDrawn " << perfLog.GetCounter(HdTokens->itemsDrawn) << std::endl; std::cout << "totalItemCount " << perfLog.GetCounter(HdTokens->totalItemCount) << std::endl; std::string imageFilePath = GetOutputFilePath(); if (!imageFilePath.empty()) { if (time != UsdTimeCode::Default()) { std::stringstream suffix; suffix << "_" << std::setw(3) << std::setfill('0') << params.frame << ".png"; imageFilePath = TfStringReplace(imageFilePath, ".png", suffix.str()); } std::cout << imageFilePath << "\n"; WriteToFile("color", imageFilePath); } i++; }