G+Smo  23.12.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
inputOutput_example.cpp

Annotated source file

Here is the full file examples/inputOutput_example.cpp. Clicking on a function or class name will lead you to its reference documentation.

// For detailed options about visualization look at gsView.cpp example.
#include <iostream>
#include <gismo.h>
using namespace gismo;
int main(int argc, char* argv[])
{
std::string input("curves3d/bspline3d_curve_01.xml");
std::string output("");
gsCmdLine cmd("Tutorial Input Output");
cmd.addPlainString("filename", "G+Smo input geometry file.", input);
cmd.addString("o", "output", "Name of the output file", output);
try { cmd.getValues(argc,argv); } catch (int rv) { return rv; }
{
gsWarn << "The file cannot be found!\n";
return EXIT_FAILURE;
}
gsInfo << "Read file \"" << input << "\"\n";
gsFileData<> fileData(input);
if (fileData.has< gsGeometry<> >())
{
pGeom = fileData.getFirst< gsGeometry<> >();
}
else
{
gsWarn << "Input file doesn't have a geometry.\n";
return EXIT_FAILURE;
}
gsInfo << "The file contains: \n" << *pGeom << "\n";
if ( output.empty() )
{
gsInfo << "Call program with option -o <basename> to write data to files\n";
gsInfo << "<basename>Paraview.vtp, <basename>Paraview.pvd, <basename>.xml\n";
return EXIT_SUCCESS;
}
// writing a paraview file
const std::string out = output + "Paraview";
gsWriteParaview(*pGeom, out);
gsInfo << "Wrote paraview files: " << out << ".vtp, " << out << ".pvd\n";
// writing a G+Smo .xml file
fd << *pGeom;
// output is a string. The extention .xml is added automatically
fd.save(output);
gsInfo << "Wrote G+Smo file: " << output << ".xml \n";
return EXIT_SUCCESS;
}