bool CellmlFile::exportTo(const QString &pFileName, const Version &pVersion) { // Export the model to the required format, after loading it if necessary if (load()) { // Check that it actually makes sense to export the model switch (pVersion) { case Cellml_1_1: { // To export to CellML 1.1, the model must be in a non CellML 1.1 // format if (version(mModel) == Cellml_1_1) return false; break; } default: // Cellml_1_0 // To export to CellML 1.0, the model must be in a non CellML 1.0 // format if (version(mModel) == Cellml_1_0) return false; } // Fully instantiate all the imports if (!fullyInstantiateImports(mModel, mIssues)) return false; // Do the actual export switch (pVersion) { case Cellml_1_1: { CellmlFileCellml11Exporter exporter(mModel, pFileName); if (exporter.errorMessage().size()) mIssues << CellmlFileIssue(CellmlFileIssue::Error, exporter.errorMessage()); return exporter.result(); } default: // Cellml_1_0 CellmlFileCellml10Exporter exporter(mModel, pFileName); if (exporter.errorMessage().size()) mIssues << CellmlFileIssue(CellmlFileIssue::Error, exporter.errorMessage()); return exporter.result(); } } else { return false; } }
void GlobalBookmarkManager::doExport(ExportType type, const QString & _path) { //it can be null when we use command line to export => there is not interface if ( KEBApp::self() && KEBApp::self()->bkInfo() ) KEBApp::self()->bkInfo()->commitChanges(); QString path(_path); // TODO - add a factory and make all this use the base class if (type == OperaExport) { if (path.isNull()) path = KOperaBookmarkImporterImpl().findDefaultLocation(true); KOperaBookmarkExporterImpl exporter(mgr(), path); exporter.write(mgr()->root()); return; } else if (type == HTMLExport) { if (path.isNull()) path = KFileDialog::getSaveFileName( QDir::homePath(), i18n("*.html|HTML Bookmark Listing"), KEBApp::self() ); HTMLExporter exporter; exporter.write(mgr()->root(), path); return; } else if (type == IEExport) { if (path.isNull()) path = KIEBookmarkImporterImpl().findDefaultLocation(true); KIEBookmarkExporterImpl exporter(mgr(), path); exporter.write(mgr()->root()); return; } bool moz = (type == MozillaExport); if (path.isNull()) { if (moz) { KMozillaBookmarkImporterImpl importer; path = importer.findDefaultLocation(true); } else { KNSBookmarkImporterImpl importer; path = importer.findDefaultLocation(true); } } if (!path.isEmpty()) { KNSBookmarkExporterImpl exporter(mgr(), path); exporter.write(mgr()->root()); } }
void tst_QVersitContactPlugins::testExporterPlugins() { QVersitContactExporter exporter("Test"); QContact contact; QContactName name; name.setFirstName("first name"); contact.saveDetail(&name); QVERIFY(exporter.exportContacts(QList<QContact>() << contact)); QCOMPARE(exporter.documents().size(), 1); QList<QVersitProperty> properties(exporter.documents().first().properties()); // The plugins have had their index set such that they should be executed in reverse order // Check that they are all loaded, and run in the correct order int n = 0; foreach (QVersitProperty property, properties) { if (property.name() == "TEST-PROPERTY") { switch (n) { case 0: QCOMPARE(property.value(), QLatin1String("5")); break; case 1: QCOMPARE(property.value(), QLatin1String("4")); break; case 2: QCOMPARE(property.value(), QLatin1String("3")); break; case 3: QCOMPARE(property.value(), QLatin1String("2")); break; case 4: QCOMPARE(property.value(), QLatin1String("1")); break; } n++; } } QCOMPARE(n, 5); }
void WaveFrontModule::exportSelectionAsOBJ(const cmd::ArgumentList& args) { const SelectionInfo& info = GlobalSelectionSystem().getSelectionInfo(); if (info.totalCount == 0) { globalErrorStream() << "Nothing selected, cannot export." << std::endl; return; } // Query the filename from the user ui::IFileChooserPtr chooser = GlobalDialogManager().createFileChooser( _("Save as Obj"), false, false, "*.obj", ".obj" ); chooser->setCurrentPath(GlobalRegistry().get(RKEY_MAP_PATH)); std::string path = chooser->display(); if (!path.empty()) { globalOutputStream() << "Exporting selection as OBJ to " << path << std::endl; // Instantiate a new exporter WaveFrontExporter exporter(path); exporter.exportSelection(); } }
void QgsComposerHtml::setExpressionContext( const QgsFeature &feature, QgsVectorLayer* layer ) { mExpressionFeature = feature; mExpressionLayer = layer; //setup distance area conversion if ( layer ) { mDistanceArea->setSourceCrs( layer->crs().srsid() ); } else if ( mComposition ) { //set to composition's mapsettings' crs mDistanceArea->setSourceCrs( mComposition->mapSettings().destinationCrs().srsid() ); } if ( mComposition ) { mDistanceArea->setEllipsoidalMode( mComposition->mapSettings().hasCrsTransformEnabled() ); } mDistanceArea->setEllipsoid( QgsProject::instance()->ellipsoid() ); // create JSON representation of feature QgsJSONExporter exporter( layer ); exporter.setIncludeRelated( true ); mAtlasFeatureJSON = exporter.exportFeature( feature ); }
__declspec(dllexport) bool oiramExport(const Config& exportConfig, HINSTANCE hInst, oiram::Serializer* serializer, bool exportSelected, HWND hLogDialog) { //CrashInstall(_T("oiramExport"), _T("1.0")); config = exportConfig; // test // char* p = 0; // *p = 1; // ³õʼ»¯Log LogManager& logMgr = LogManager::getSingleton(); std::string logFileName = config.exportPath + config.maxName + ".log"; logMgr.initialize(logFileName, hLogDialog); // µ¼³ö Exporter exporter(serializer); bool result = exporter.Export(exportSelected); logMgr.uninitialize(); //CrashUninstall(); return result; }
// ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- vtkDataSet *ConvertEAVLToVTK(eavlDataSet *in) { ostringstream stream; eavlVTKExporter exporter(in); exporter.Export(stream); string str = stream.str(); // ofstream tmp; tmp.open("./eavl_to_vtk_str.out", std::ios_base::out); // tmp.write(str.c_str(),str.length()); // tmp.close(); // Note: VisIt does this: (I ask because we're getting a 1-byte // invalid read in valgrind; maybe this fixes it?): //vtkCharArray *charArray = vtkCharArray::New(); //int iOwnIt = 1; // 1 means we own it -- you don't delete it. //charArray->SetArray((char *) asCharTmp, asCharLengthTmp, iOwnIt); //reader->SetReadFromInputString(1); //reader->SetInputArray(charArray); vtkDataSetReader *rdr = vtkDataSetReader::New(); rdr->ReadAllScalarsOn(); rdr->ReadAllVectorsOn(); rdr->ReadAllTensorsOn(); rdr->SetReadFromInputString(1); rdr->SetInputString(str.c_str()); vtkDataSet *out = rdr->GetOutput(); rdr->Update(); out->Register(NULL); rdr->Delete(); return out; }
// ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- vtkDataSet *ConvertEAVLToVTK(eavlDataSet *in) { ostringstream stream; eavlVTKExporter exporter(in); exporter.Export(stream); string str = stream.str(); // Note: VisIt does this: (I ask because we're getting a 1-byte // invalid read in valgrind; maybe this fixes it?): //vtkCharArray *charArray = vtkCharArray::New(); //int iOwnIt = 1; // 1 means we own it -- you don't delete it. //charArray->SetArray((char *) asCharTmp, asCharLengthTmp, iOwnIt); //reader->SetReadFromInputString(1); //reader->SetInputArray(charArray); vtkDataSetReader *rdr = vtkDataSetReader::New(); rdr->SetReadFromInputString(1); rdr->SetInputString(str.c_str()); vtkDataSet *out = rdr->GetOutput(); rdr->Update(); out->Register(NULL); rdr->Delete(); return out; }
// ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to 3DS. Prototyped and registered in Exporter.cpp void ExportScene3DS(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) { boost::shared_ptr<IOStream> outfile (pIOSystem->Open(pFile, "wb")); if(!outfile) { throw DeadlyExportError("Could not open output .3ds file: " + std::string(pFile)); } // TODO: This extra copy should be avoided and all of this made a preprocess // requirement of the 3DS exporter. // // 3DS meshes can be max 0xffff (16 Bit) vertices and faces, respectively. // SplitLargeMeshes can do this, but it requires the correct limit to be set // which is not possible with the current way of specifying preprocess steps // in |Exporter::ExportFormatEntry|. aiScene* scenecopy_tmp; SceneCombiner::CopyScene(&scenecopy_tmp,pScene); std::auto_ptr<aiScene> scenecopy(scenecopy_tmp); SplitLargeMeshesProcess_Triangle tri_splitter; tri_splitter.SetLimit(0xffff); tri_splitter.Execute(scenecopy.get()); SplitLargeMeshesProcess_Vertex vert_splitter; vert_splitter.SetLimit(0xffff); vert_splitter.Execute(scenecopy.get()); // Invoke the actual exporter Discreet3DSExporter exporter(outfile, scenecopy.get()); }
TEST_F(TransientTests, TestProjection) { FunctionPtr u_exact = Teuchos::rcp( new InletBC ); map<int, Teuchos::RCP<Function> > functionMap; functionMap[u->ID()] = u_exact; solution->projectOntoMesh(functionMap); FunctionPtr u_prev = Teuchos::rcp( new PreviousSolutionFunction(solution, u) ); FunctionPtr u_sqr = (u_prev - u_exact)*(u_prev - u_exact); double L2_error_before_ref = sqrt(u_sqr->integrate(mesh)); #ifdef USE_VTK bool savePlots = false; VTKExporter exporter(solution, mesh, varFactory); if (savePlots) exporter.exportFunction(u_prev, "u_prev"); #endif double energyThreshold = 0.2; // for mesh refinements RefinementStrategy refinementStrategy( solution, energyThreshold ); vector<GlobalIndexType> cellsToRefine; cellsToRefine.push_back(1); cellsToRefine.push_back(2); refinementStrategy.hRefineCells(mesh, cellsToRefine); #ifdef USE_VTK if (savePlots) exporter.exportFunction(u_prev, "u_ref"); #endif u_sqr = (u_prev - u_exact)*(u_prev - u_exact); double L2_error_after_ref = sqrt(u_sqr->integrate(mesh)); double tol = 1e-8; EXPECT_NEAR(L2_error_after_ref, L2_error_before_ref, tol) << "Refinement increases error"; }
void exportP0EltMarkerFromFaceMarker() { this->updateP0EltMarkerFromFaceMarker(); auto myexporter = exporter( _mesh=M_mesh, _name="MyExportMarkP0Elt" ); myexporter->step(0)->add( "markP0Elt", *M_markP0Elt ); myexporter->save(); }
Value* RornUtils_ExportCompileAndView_cf(Value** arg_list, int count) { check_arg_count(RornUtils_ExportCompileAndView, 1, count); Value* exportPathValue = arg_list[0]; Rorn::Text::ci_string exportPath( exportPathValue->to_string() ); SceneExporter exporter(GetCOREInterface()); exporter.ExportScene( exportPath ); // compile std::string modelCompilerPathname; Rorn::WindowsRegistry::GetRegistryTextValue(Rorn::WindowsRegistry::LocalMachine, "SOFTWARE\\Riversoft\\Rorn", "ModelCompilerPathname", modelCompilerPathname); Rorn::Text::ci_string compiledModelPathname = Rorn::Text::Path::ChangeExtension(exportPath, "model"); std::stringstream compilerArgumentsStream; compilerArgumentsStream << "\"" << modelCompilerPathname.c_str() << "\" \"" << exportPath.c_str() << "\" \"" << compiledModelPathname.c_str() << "\""; std::string modelCompilerOutput; int compilerExitCode = Rorn::Process::RunCommandLineApplication(modelCompilerPathname.c_str(), compilerArgumentsStream.str().c_str(), modelCompilerOutput); // view std::string modelViewerPathname; Rorn::WindowsRegistry::GetRegistryTextValue(Rorn::WindowsRegistry::LocalMachine, "SOFTWARE\\Riversoft\\Rorn", "ModelViewerPathname", modelViewerPathname); Rorn::Process::LaunchApplication(modelViewerPathname.c_str(), compiledModelPathname.c_str()); return &ok; }
void QgsLayoutItemHtml::setExpressionContext( const QgsFeature &feature, QgsVectorLayer *layer ) { mExpressionFeature = feature; mExpressionLayer = layer; //setup distance area conversion if ( layer ) { mDistanceArea.setSourceCrs( layer->crs() ); } else if ( mLayout ) { #if 0 //TODO //set to composition's mapsettings' crs QgsComposerMap *referenceMap = mComposition->referenceMap(); if ( referenceMap ) mDistanceArea->setSourceCrs( referenceMap->crs() ); #endif } if ( mLayout ) { mDistanceArea.setEllipsoid( mLayout->project()->ellipsoid() ); } // create JSON representation of feature QgsJsonExporter exporter( layer ); exporter.setIncludeRelated( true ); mAtlasFeatureJSON = exporter.exportFeature( feature ); }
void TestInterpolationHDiv<Dim>::testInterpolationOneElt( std::string one_element_mesh ) { // expr to interpolate int is3D = 0; if( Dim == 3 ) is3D = 1; auto myexpr = unitX() + unitY() + is3D*unitZ() ; //(1,1) // one element mesh auto mesh_name = one_element_mesh + ".msh"; //create the mesh and load it fs::path mesh_path( mesh_name ); mesh_ptrtype oneelement_mesh = loadMesh( _mesh=new mesh_type, _filename=mesh_name); // refined mesh (export) auto refine_level = std::floor(1 - math::log( 0.1 )); //Deduce refine level from meshSize (option) mesh_ptrtype mesh = loadMesh( _mesh=new mesh_type, _filename=mesh_name, _refine=( int )refine_level); space_ptrtype Xh = space_type::New( oneelement_mesh ); //std::cout << "nb dof = " << Xh->nDof() << std::endl; std::vector<std::string> faces; if(Dim == 2) faces = { "hypo","vert","hor"}; else if (Dim == 3) faces = {"xzFace","xyFace","xyzFace","yzFace"}; element_type U_h_int = Xh->element(); element_type U_h_on = Xh->element(); // handly computed interpolant coeff (in hdiv basis) for ( int i = 0; i < Xh->nLocalDof(); ++i ) { CHECK( mesh->hasMarkers( {faces[i]} ) ); U_h_int(i) = integrate( markedfaces( oneelement_mesh, faces[i] ), trans( N() )*myexpr ).evaluate()(0,0); } // raviart-thomas interpolant using on U_h_on.zero(); U_h_on.on(_range=elements(oneelement_mesh), _expr=myexpr); auto exporter_proj = exporter( _mesh=mesh, _name=( boost::format( "%1%-%2%" ) % this->about().appName() %mesh_path.stem().string() ).str() ); exporter_proj->step( 0 )->add( "U_interpolation_handly-" + mesh_path.stem().string(), U_h_int ); exporter_proj->step( 0 )->add( "U_interpolation_on-" + mesh_path.stem().string(), U_h_on ); exporter_proj->save(); U_h_int.printMatlab( "U_h_int_" + mesh_path.stem().string() + ".m" ); U_h_on.printMatlab( "U_h_on_" + mesh_path.stem().string() + ".m" ); //L2 norm of error auto error = vf::project(_space=Xh, _range=elements(oneelement_mesh), _expr=idv(U_h_int) - idv(U_h_on) ); double L2error = error.l2Norm(); std::cout << "L2 error = " << L2error << std::endl; }
void TestInterpolationHCurl::testInterpolation( std::string one_element_mesh ) { // expr to interpolate auto myexpr = unitX() + unitY(); //(1,1) // one element mesh auto mesh_name = one_element_mesh + ".msh"; //create the mesh and load it fs::path mesh_path( mesh_name ); mesh_ptrtype oneelement_mesh = loadMesh( _mesh=new mesh_type, _filename=mesh_name); // refined mesh (export) auto refine_level = std::floor(1 - math::log( 0.1 )); //Deduce refine level from meshSize (option) mesh_ptrtype mesh = loadMesh( _mesh=new mesh_type, _filename=mesh_name, _refine=( int )refine_level); space_ptrtype Xh = space_type::New( oneelement_mesh ); std::vector<std::string> faces, edges; //list of edges edges = {"hypo","vert","hor"}; element_type U_h_int = Xh->element(); element_type U_h_on = Xh->element(); element_type U_h_on_boundary = Xh->element(); // handly computed interpolant coeff (in hcurl basis) for ( int i = 0; i < Xh->nLocalDof(); ++i ) { CHECK( oneelement_mesh->hasMarkers( {edges[i]} ) ); U_h_int(i) = integrate( markedfaces( oneelement_mesh, edges[i] ), trans( T() )*myexpr ).evaluate()(0,0); } // nedelec interpolant using on U_h_on.zero(); U_h_on.on(_range=elements(oneelement_mesh), _expr=myexpr); U_h_on_boundary.on(_range=boundaryfaces(oneelement_mesh), _expr=myexpr); auto exporter_proj = exporter( _mesh=mesh, _name=( boost::format( "%1%" ) % this->about().appName() ).str() ); exporter_proj->step( 0 )->add( "U_interpolation_handly_"+mesh_path.stem().string(), U_h_int ); exporter_proj->step( 0 )->add( "U_interpolation_on_"+mesh_path.stem().string(), U_h_on ); exporter_proj->save(); // print coefficient only for reference element U_h_int.printMatlab( "U_h_int_" + mesh_path.stem().string() + ".m" ); U_h_on.printMatlab( "U_h_on_" + mesh_path.stem().string() + ".m" ); U_h_on_boundary.printMatlab( "U_h_on_boundary_" + mesh_path.stem().string() + ".m" ); //L2 norm of error auto error = vf::project(_space=Xh, _range=elements(oneelement_mesh), _expr=idv(U_h_int) - idv(U_h_on) ); double L2error = error.l2Norm(); std::cout << "L2 error (elements) = " << L2error << std::endl; auto error_boundary = vf::project(_space=Xh, _range=boundaryfaces(oneelement_mesh), _expr=idv(U_h_int) - idv(U_h_on_boundary) ); double L2error_boundary = error_boundary.l2Norm(); std::cout << "L2 error (boundary) = " << L2error_boundary << std::endl; BOOST_CHECK_SMALL( L2error_boundary - L2error, 1e-13 ); }
std::tr1::shared_ptr<AegiVideoFrame> ThreadedFrameSource::ProcFrame(int frameNum, double time, bool raw) { std::tr1::shared_ptr<AegiVideoFrame> frame(new AegiVideoFrame, delete_frame); { wxMutexLocker locker(providerMutex); try { frame->CopyFrom(videoProvider->GetFrame(frameNum)); } catch (VideoProviderError const& err) { throw VideoProviderErrorEvent(err); } } // This deliberately results in a call to LoadSubtitles while a render // is pending making the queued render use the new file if (!raw) { try { wxMutexLocker locker(fileMutex); if (subs.get() && singleFrame != frameNum) { // Generally edits and seeks come in groups; if the last thing done // was seek it is more likely that the user will seek again and // vice versa. As such, if this is the first frame requested after // an edit, only export the currently visible lines (because the // other lines will probably not be viewed before the file changes // again), and if it's a different frame, export the entire file. if (singleFrame == -1) { AssExporter exporter(subs.get()); exporter.AddAutoFilters(); exporter.ExportTransform(); singleFrame = frameNum; // Copying a nontrivially sized AssFile is fairly slow, so // instead muck around with its innards to just temporarily // remove the non-visible lines without deleting them std::list<AssEntry*> visible; std::remove_copy_if(subs->Line.begin(), subs->Line.end(), std::back_inserter(visible), invisible_line(time)); try { std::swap(subs->Line, visible); provider->LoadSubtitles(subs.get()); std::swap(subs->Line, visible); } catch(...) { std::swap(subs->Line, visible); throw; } } else { provider->LoadSubtitles(subs.get()); subs.reset(); } } } catch (wxString const& err) { throw SubtitlesProviderErrorEvent(err); } provider->DrawSubtitles(*frame, time); } return frame; }
void Scene::output(const string &filename) const { HTMLExporter exporter(filename, "Scene: " + id); ObjectInstance::output(exporter, "All objects", objects); for (const Agent &a : agents) a.output(exporter); }
// ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to PLY. Prototyped and registered in Exporter.cpp void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) { // invoke the exporter PlyExporter exporter(pFile, pScene); // we're still here - export successfully completed. Write the file. boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt")); outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1); }
void WriteToVTKFile(eavlDataSet *data, const string &filename, int cellSetIndex = 0) { ofstream *p = new ofstream(filename.c_str()); ostream *s = p; eavlVTKExporter exporter(data, cellSetIndex); exporter.Export(*s); p->close(); delete p; }
void WriteToVTKFile(eavlDataSet *data, const string &filename, int cellSetIndex = 0) { ofstream out(filename.c_str()); eavlVTKExporter exporter(data, cellSetIndex); exporter.Export(out); out.close(); }
bool Preferences_Save( PreferenceDictionary& preferences, const char* filename ){ TextFileOutputStream file( filename ); if ( !file.failed() ) { XMLStreamWriter writer( file ); XMLPreferenceDictionaryExporter exporter( preferences, PREFERENCES_VERSION ); exporter.exportXML( writer ); return true; } return false; }
void MainWindow::exportRecord() { if( !carna.get() ) { return; } Exporter exporter( server, this ); exporter.install( new BinaryDumpProcessor() ); exporter.run(); }
void CPairTrade::exportSymbol(Inqueue::ContextAccessor& historyaccessor, CppUtils::String const& symbol, int const cache_id) { CppUtils::String fileExportMame = baseExportPath_m + "\\"+ symbol + ".txt"; Math::ExporterEngine<Math::PriceSeriesProvider> exporter(fileExportMame, false); bool result = historyaccessor.callMathEngine<bool, Math::P_CloseBid, Math::ExporterEngine<Math::PriceSeriesProvider> >(cache_id, exporter); if (!result) { LOG_SYMBOL_PROBLEM(connectRunName_m,getBarDataProvider_Smartcom(), symbol,"Cannot export symbol to: " << fileExportMame ); } }
void Activity::output(const string &filename) const { HTMLExporter exporter(filename, "Activity: " + id); supportDistribution.output(exporter, "support distribution"); objectGroupDistribution->output(exporter, "object group distribution"); exporter.appendHeader1("Category distributions"); for (const auto &p : categoryDistributions) p.second.output(exporter); }
void cv<Dim,Order>::run() { auto mesh = loadMesh(_mesh = new mesh_type ,_update = MESH_CHECK|MESH_UPDATE_FACES|MESH_UPDATE_EDGES|MESH_RENUMBER ); auto Xh = space_type::New( mesh ); auto phi = Xh->element(); phi = vf::project(Xh,elements(mesh),Px()+Py()); auto e = exporter(_mesh= mesh,_name= "myExporter"); e->add( "phi", phi ); e->save(); }
void Map::exportSelected(std::ostream& out) { MapFormatPtr format = getFormat(); IMapWriterPtr writer = format->getMapWriter(); // Create our main MapExporter walker for traversal MapExporter exporter(*writer, GlobalSceneGraph().root(), out); // Pass the traverseSelected function and start writing selected nodes exporter.exportMap(GlobalSceneGraph().root(), traverseSelected); }
void MainWindow::on_actionExport_triggered() { if(project != 0) { QFileInfo fileinfo(project->filename); QString filename = QFileDialog::getSaveFileName(this, "Export prints", fileinfo.absolutePath() + "/" + fileinfo.baseName(), "Portable Network Graphics (*.png)"); PrintExporter exporter((QFileInfo(filename))); project->Export(exporter); } }
Value* RornUtils_Export_cf(Value** arg_list, int count) { check_arg_count(RornUtils_Export, 1, count); Value* exportPathValue = arg_list[0]; Rorn::Text::ci_string exportPath( exportPathValue->to_string() ); SceneExporter exporter(GetCOREInterface()); exporter.ExportScene( exportPath ); return &ok; }
void ExportScenePlyBinary(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) { // invoke the exporter PlyExporter exporter(pFile, pScene, true); // we're still here - export successfully completed. Write the file. boost::scoped_ptr<IOStream> outfile(pIOSystem->Open(pFile, "wb")); if (outfile == NULL) { throw DeadlyExportError("could not open output .ply file: " + std::string(pFile)); } outfile->Write(exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()), 1); }
void Synthesizer::outputState(const string &filename) const { HTMLExporter exporter(filename, "Synthesis scene state: " + scene.id); ObjectInstance::output(exporter, "All objects", scene.objects); for (const Agent &a : scene.agents) a.output(exporter); if (active.score < 0.0) { exporter.appendBoldText("No active object", ""); } else { exporter.appendHeader1("Active object: " + active.object.model->categoryName); exporter.appendBoldText("Agents: ", ml::convert::toString(active.agents)); exporter.appendBoldText("Parent: ", scene.objects[active.parentObjectIndex].object.model->categoryName + "-" + std::to_string(active.parentObjectIndex)); exporter.appendBoldText("Support: ", ml::convert::toString(active.isAgentSupport)); exporter.appendBoldText("Score: ", ml::convert::toString(active.score)); } exporter.appendHeader1("Synthesis agent state"); for (const SynthesizerAgent &agent : agents) { exporter.appendHeader2("Agent: " + agent.agent->activity); if (agent.supportObjectPlaced) { exporter.appendBoldText("Support object placed", ""); } else if (agent.supportObject.model != nullptr) { exporter.appendBoldText("Support object: ", agent.supportObject.model->categoryName); } ml::Grid2<string> grid(2, agent.objectsToPlace.size()); int col = 0; for (const DisembodiedObject &object : agent.objectsToPlace) { grid(0, col) = object.model->imageHTML(); grid(1, col) = "<b>" + object.model->categoryName + "</b>"; col++; } exporter.appendTableColumnWrap("Objects to place", grid, 10); } exporter.appendHeader1("Placement locations: " + locations.size()); }