G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsView.cpp

Annotated source file

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

#include <iostream>
#include <gismo.h>
using namespace gismo;
int main(int argc, char *argv[])
{
std::string pname("gsview"), fn("");
index_t numSamples(1000);
index_t choice(0);
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;
gsFileData<> filedata(fn);
switch ( choice )
{
case 3:
{
gsBasis<>::uPtr bb = filedata.getAnyFirst< gsBasis<> >();
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:
{
gsGeometry<>::uPtr geo = filedata.getAnyFirst< gsGeometry<> >();
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:
if ( filedata.has< gsMultiPatch<> >() )
{
filedata.getFirst(mp);
gsInfo<< "Got "<< mp <<"\n";
if (plot_patchid)
{
gsWriteParaview(nfield, pname, numSamples);
}
else
{
gsWriteParaview(mp, pname, numSamples, plot_mesh, plot_net);
}
break;
}
if ( filedata.has< gsGeometry<> >() )
{
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 ( filedata.has< gsSurfMesh >() )
{
auto msh = filedata.getFirst< gsSurfMesh >();
if (msh)
gsInfo<< "Got "<< *msh <<"\n";
else
{
gsInfo<< "Problem encountered in file "<<fn<<", quitting." <<"\n";
return 0;
}
gsWriteParaview( *msh, pname);
gsFileManager::open(pname+".vtk");
return EXIT_SUCCESS;
break;
}
if ( filedata.has< gsBasis<> >() )
{
gsBasis<>::uPtr bb = filedata.getFirst< gsBasis<> >();
//bb->uniformRefine(3);
if (bb)
gsInfo<< "Got "<< *bb <<"\n";
else
{
gsInfo<< "Problem encountered in file "<<fn<<", quitting." <<"\n";
return 0;
}
gsWriteParaview( *bb , pname, numSamples, plot_mesh);
break;
}
if ( filedata.has< gsSolid<> >() )
{
gsSolid<>::uPtr bb = filedata.getFirst< gsSolid<> >();
if (bb)
gsInfo<< "Got "<< *bb <<"\n";
else
{
gsInfo<< "Problem encountered in file "<<fn<<", quitting." <<"\n";
return 0;
}
gsWriteParaviewSolid( *bb, pname, numSamples);
//gsWriteParaview( *bb, pname, numSamples, 0, 0.02);
break;
}
if ( filedata.has< gsTrimSurface<> >() )
{
gsTrimSurface<>::uPtr bb = filedata.getFirst< gsTrimSurface<> >();
//bb->uniformRefine(3);
if (bb)
gsInfo<< "Got "<< *bb <<"\n";
else
{
gsInfo<< "Problem encountered in file "<<fn<<", quitting." <<"\n";
return 0;
}
gsWriteParaview( *bb, pname, numSamples);
break;
}
if ( filedata.has< gsPlanarDomain<> >() )
{
gsPlanarDomain<>::uPtr bb = filedata.getFirst< gsPlanarDomain<> >();
//bb->uniformRefine(3);
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;
}
if ( filedata.has< gsMatrix<> >() )
{
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;
}
gsFileManager::open(pname+".pvd");
return EXIT_SUCCESS;
}
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition gsBasis.h:89
Class for command-line argument parsing.
Definition gsCmdLine.h:57
A scalar of vector field defined on a m_parametric geometry.
Definition gsField.h:55
This class represents an XML data tree which can be read from or written to a (file) stream.
Definition gsFileData.h:34
static void open(const std::string &fn)
Opens the file fn using the preferred application of the OS.
Definition gsFileManager.cpp:688
index_t size() const
size
Definition gsFunction.h:295
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
memory::unique_ptr< gsGeometry > uPtr
Unique pointer for gsGeometry.
Definition gsGeometry.h:100
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Class Representing a triangle mesh with 3D vertices.
Definition gsMesh.h:32
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition gsMultiPatch.h:100
Class representing a Planar domain with an outer boundary and a number of holes.
Definition gsPlanarDomain.h:44
Class for representing a solid made up of vertices, edges, faces, and volumes.
Definition gsSolid.h:33
A halfedge data structure for polygonal meshes.
Definition gsSurfMesh.h:46
Class for a trim surface.
Definition gsTrimSurface.h:34
Main header to be included by clients using the G+Smo library.
#define index_t
Definition gsConfig.h:32
#define gsInfo
Definition gsDebug.h:43
std::vector< T * > get_raw(const std::vector< unique_ptr< T > > &cont)
Takes a vector of smart pointers and returns the corresponding raw pointers.
Definition gsMemory.h:208
The G+Smo namespace, containing all definitions for the library.
void gsWriteParaviewSolid(gsSolid< T > const &sl, std::string const &fn, unsigned numSamples=NS)
Export a gsSolid to Paraview file.
Definition gsWriteParaview.hpp:1781
Class that creates standard fields on a given parametric (multipatch) geometry.
Definition gsFieldCreator.h:333