render_option.cc
Go to the documentation of this file.
//
// manage graphical render options
// e.g. print it in python for the rheolef_paraview.py script
//
// author: Pierre.Saramito@imag.fr
//
// date: 25 janv 2020
//
#include "rheolef/render_option.h"
namespace rheolef {
// ----------------------------------------------------------------------------
// option for scalar visualization with paraview
// ----------------------------------------------------------------------------
render_option::render_option()
: showlabel(), stereo(), elevation(), iso(), cut(), grid(), fill(), volume(), view_2d(),
view_map(), high_order(), color(), gray(), black_and_white(), have_opacity_bug(),
n_isovalue(), n_isovalue_negative(), branch_size(1),
scale(), f_min(), f_max(), isovalue(),
resolution(),
xmin(), xmax(), origin(), normal(),
format(), mark(), label(), valued(), style()
{
}
std::ostream& operator << (std::ostream& py, const render_option& popt)
{
popt.put_paraview (py); return py;
}
void render_option::put_paraview (std::ostream& py) const
{
using namespace std;
if (format == "tiff") format = "tif";
if (format == "jpeg") format = "jpg";
if (black_and_white) fill = false;
string color_str = (color ? "color" : (gray ? "gray" : "black_and_white"));
if (isovalue != numeric_limits<Float>::max()) {
n_isovalue = 2; // draw {min, isovalue, max} when color : two bands
}
if (label == "") label = mark;
if (normal[0] == numeric_limits<Float>::max()) normal = point(1,0,0);
py << setprecision (numeric_limits<Float>::digits10)
<< "#!/usr/bin/env paraview --script=" << endl
<< "# This is a paraview script, automatically generated by rheolef." << endl
<< endl
<< "from paraview.simple import *" << endl
<< "from paraview_rheolef import * # load rheolef specific functions" << endl
<< endl
<< "opt = { \\" << endl
<< " 'format' : '" << format << "', \\" << endl
<< " 'resolution' : [" << resolution[0] << "," << resolution[1] << "], \\" << endl
<< " 'branch_size' : " << branch_size << ", \\" << endl
<< " 'mark' : '" << mark << "', \\" << endl
<< " 'label' : '" << label << "', \\" << endl
<< " 'showlabel': " << showlabel << ", \\" << endl
<< " 'axis' : 1, \\" << endl
<< " 'color' : '" << color_str << "', \\" << endl
<< " 'have_opacity_bug' : " << have_opacity_bug << ", \\" << endl
<< " 'stereo' : " << stereo << ", \\" << endl
<< " 'bbox' : [[" << xmin[0] << "," << xmin[1] << "," << xmin[2] << "],["
<< xmax[0] << "," << xmax[1] << "," << xmax[2] << "]], \\" << endl
<< " 'scale' : " << scale << ", \\" << endl
<< " 'elevation' : " << elevation << ", \\" << endl
<< " 'range' : [" << f_min << ", " << f_max << "], \\" << endl
<< " 'iso' : " << iso << ", \\" << endl
<< " 'isovalue' : " << isovalue << ", \\" << endl
<< " 'n_isovalue' : " << n_isovalue << ", \\" << endl
<< " 'n_isovalue_negative' : " << n_isovalue_negative << ", \\" << endl
<< " 'cut' : " << cut << ", \\" << endl
<< " 'origin' : " << python(origin) << ", \\" << endl
<< " 'normal' : " << python(normal) << ", \\" << endl
<< " 'grid' : " << grid << ", \\" << endl
<< " 'fill' : " << fill << ", \\" << endl
<< " 'volume' : " << volume << ", \\" << endl
<< " 'view_1d' : 0, \\" << endl
<< " 'view_2d' : " << view_2d << ", \\" << endl
<< " 'view_map' : " << view_map << ", \\" << endl
<< " 'high_order' : "<< high_order << ", \\" << endl
<< " 'valued' : '"<< valued << "', \\" << endl
<< " 'style' : '"<< style << "' \\" << endl
<< "}" << endl
<< endl
;
}
std::string
render_option::python (const point& x, size_t d)
{
std::ostringstream os;
os << "(" << x[0];
for (size_t i = 1; i < d; i++)
os << ", " << x[i];
os << ")" << std::flush;
std::string buffer = os.str();
return buffer;
}
} // namespace rheolef
rheolef::render_option::f_max
Float f_max
Definition: render_option.h:47
rheolef::render_option::origin
point origin
Definition: render_option.h:49
rheolef::render_option::grid
bool grid
Definition: render_option.h:44
rheolef::normal
details::field_expr_v2_nonlinear_terminal_function< details::normal_pseudo_function< Float > > normal()
normal: see the expression page for the full documentation
Definition: field_expr_terminal.h:439
rheolef::render_option::black_and_white
bool black_and_white
Definition: render_option.h:45
rheolef::render_option::render_option
render_option()
Definition: render_option.cc:34
rheolef::render_option::color
bool color
Definition: render_option.h:45
rheolef::render_option::put_paraview
void put_paraview(std::ostream &py) const
Definition: render_option.cc:48
rheolef::render_option::fill
bool fill
Definition: render_option.h:44
rheolef::render_option::elevation
bool elevation
Definition: render_option.h:44
rheolef::render_option::f_min
Float f_min
Definition: render_option.h:47
rheolef::render_option::view_map
bool view_map
Definition: render_option.h:45
rheolef::render_option::xmin
point xmin
Definition: render_option.h:49
rheolef::render_option::gray
bool gray
Definition: render_option.h:45
rheolef::render_option::branch_size
size_t branch_size
Definition: render_option.h:46
rheolef::render_option::n_isovalue
size_t n_isovalue
Definition: render_option.h:46
rheolef::render_option::stereo
bool stereo
Definition: render_option.h:44
rheolef::render_option::python
static std::string python(const point &x, size_t d=3)
rheolef::render_option::cut
bool cut
Definition: render_option.h:44
rheolef::render_option::mark
std::string mark
Definition: render_option.h:50
rheolef::render_option::scale
Float scale
Definition: render_option.h:47
rheolef::render_option::volume
bool volume
Definition: render_option.h:44
rheolef::render_option::high_order
bool high_order
Definition: render_option.h:45
rheolef::render_option::xmax
point xmax
Definition: render_option.h:49
rheolef::render_option::normal
point normal
Definition: render_option.h:49
gray
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin gray
Definition: iorheo-members.h:62
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::render_option::label
std::string label
Definition: render_option.h:50
rheolef::render_option
Definition: render_option.h:38
rheolef::point
point_basic< Float > point
Definition: point.h:164
point
see the point page for the full documentation
mkgeo_ball.d
d
Definition: mkgeo_ball.sh:154
rheolef::render_option::isovalue
Float isovalue
Definition: render_option.h:47
rheolef::render_option::resolution
point_basic< size_t > resolution
Definition: render_option.h:48
rheolef::render_option::style
std::string style
Definition: render_option.h:50
rheolef::render_option::iso
bool iso
Definition: render_option.h:44
rheolef::render_option::have_opacity_bug
bool have_opacity_bug
Definition: render_option.h:45
rheolef::operator<<
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
rheolef::render_option::showlabel
bool showlabel
Definition: render_option.h:44
rheolef::render_option::n_isovalue_negative
size_t n_isovalue_negative
Definition: render_option.h:46
rheolef::render_option::valued
std::string valued
Definition: render_option.h:50
rheolef::std
Definition: vec_expr_v2.h:391
rheolef::render_option::view_2d
bool view_2d
Definition: render_option.h:44
rheolef::render_option::format
std::string format
Definition: render_option.h:50