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.
#include <iostream>
using namespace gismo;
int main(
int argc,
char* argv[])
{
std::string input("curves3d/bspline3d_curve_01.xml");
std::string 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";
{
}
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, <basename>ControlPoints.csv\n";
return EXIT_SUCCESS;
}
const std::string out = output + "Paraview";
gsWriteParaview(*pGeom, out);
gsInfo << "Wrote paraview files: " << out << ".vtp, " << out << ".pvd\n";
fd << *pGeom;
gsInfo << "Wrote G+Smo file: " << output << ".xml \n";
if (pGeom->targetDim()==2)
gsWriteCsv(output+
".csv", pGeom->coefs(), {
"X",
"Y"});
else if (pGeom->targetDim()==3)
gsWriteCsv(output+
".csv", pGeom->coefs(), {
"X",
"Y",
"Z"});
gsInfo << "Wrote CSV file: " << output+".csv \n";
return EXIT_SUCCESS;
}