#include <iostream>
using namespace gismo;
int main(
int argc,
char *argv[])
{
std::string pname("gsview"), fn("");
bool plot_mesh = false;
bool plot_net = false;
bool plot_patchid = false;
bool get_basis = false;
bool get_mesh = false;
bool get_geo = false;
gsCmdLine cmd(
"Hi, give me a file (eg: .xml) and I will try to draw it!");
cmd.addSwitch("geometry", "Try to find and plot a geometry contained in the file", get_geo);
cmd.addSwitch("mesh" , "Try to find and plot a mesh contained in the file", get_mesh);
cmd.addSwitch("basis" , "Try to find and plot a basis contained in the file", get_basis);
cmd.addInt ("s", "samples", "Number of samples to use for viewing", numSamples);
cmd.addSwitch("element" , "Plot the element mesh (when applicable)", plot_mesh);
cmd.addSwitch("controlNet", "Plot the control net (when applicable)", plot_net);
cmd.addSwitch("pid" , "Plot the ID of each patch and boudanries as color", plot_patchid);
cmd.addPlainString("filename", "File containing data to draw (.xml or third-party)", fn);
cmd.addString("o", "oname", "Filename to use for the ParaView output", pname);
try { cmd.getValues(argc,argv); } catch (int rv) { return rv; }
if ( fn.empty() )
{
gsInfo<< cmd.getMessage();
gsInfo<<"\nType "<< argv[0]<< " -h, to get the list of command line options.\n";
return 0;
}
if (get_basis)
choice = 3;
else if (get_mesh)
choice = 4;
else if (get_geo)
choice = 5;
switch ( choice )
{
case 3:
{
if (bb)
gsInfo<< "Got "<< *bb <<"\n";
else
{
gsInfo<< "Did not find any basis to plot in "<<fn<<", quitting."<<"\n";
return 0;
}
gsWriteParaview( *bb , pname, numSamples, true);
break;
}
case 4:
{
gsMesh<>::uPtr msh = filedata.getAnyFirst<
gsMesh<> >();
if (msh)
gsInfo<< "Got "<< *msh <<"\n";
else
{
gsInfo<< "Did not find any mesh to plot in "<<fn<<", quitting."<<"\n";
return 0;
}
gsWriteParaview( *msh, pname);
break;
}
case 5:
{
if (geo)
gsInfo<< "Got "<< *geo <<"\n";
else
{
gsInfo<< "Did not find any geometry to plot in "<<fn<<", quitting."<<"\n";
return 0;
}
gsWriteParaview( *geo , pname, numSamples, plot_mesh, plot_net);
break;
}
default:
{
filedata.getFirst(mp);
gsInfo<< "Got "<< mp <<"\n";
if (plot_patchid)
{
gsWriteParaview(nfield, pname, numSamples);
}
else
{
gsWriteParaview(mp, pname, numSamples, plot_mesh, plot_net);
}
break;
}
{
std::vector<gsGeometry<>::uPtr> geo = filedata.getAll<
gsGeometry<> >();
if ( ! geo.empty() )
gsInfo<<
"Got "<< geo.
size() <<
" patch"<<(geo.size() == 1 ?
"." :
"es.") <<
"\n";
else
{
gsInfo<< "Problem encountered in file "<<fn<<", quitting." <<"\n";
return 0;
}
gsWriteParaview(
memory::get_raw(geo), pname, numSamples, plot_mesh, plot_net);
break;
}
{
if (msh)
gsInfo<< "Got "<< *msh <<"\n";
else
{
gsInfo<< "Problem encountered in file "<<fn<<", quitting." <<"\n";
return 0;
}
gsWriteParaview( *msh, pname);
return EXIT_SUCCESS;
break;
}
{
if (bb)
gsInfo<< "Got "<< *bb <<"\n";
else
{
gsInfo<< "Problem encountered in file "<<fn<<", quitting." <<"\n";
return 0;
}
gsWriteParaview( *bb , pname, numSamples, plot_mesh);
break;
}
{
gsSolid<>::uPtr bb = filedata.getFirst<
gsSolid<> >();
if (bb)
gsInfo<< "Got "<< *bb <<"\n";
else
{
gsInfo<< "Problem encountered in file "<<fn<<", quitting." <<"\n";
return 0;
}
break;
}
{
if (bb)
gsInfo<< "Got "<< *bb <<"\n";
else
{
gsInfo<< "Problem encountered in file "<<fn<<", quitting." <<"\n";
return 0;
}
gsWriteParaview( *bb, pname, numSamples);
break;
}
{
if (bb)
gsInfo<< "Got "<< *bb <<"\n";
else
{
gsInfo<< "Problem encountered in file "<<fn<<", quitting." <<"\n";
return 0;
}
gsMesh<>::uPtr msh = bb->toMesh(numSamples);
gsWriteParaview( *msh , pname);
break;
}
{
filedata.getFirst(bb);
gsInfo<< "Got Matrix with "<< bb.cols() <<" points.\n";
gsInfo<< "Plot "<< bb.rows() <<"D points.\n";
gsWriteParaviewPoints<real_t>( bb, pname);
break;
}
gsInfo<< "Did not find anything to plot in "<<fn<<", quitting."<<"\n";
return 0;
}
return EXIT_SUCCESS;
}