Rheolef  7.1
an efficient C++ finite element environment
render_option.cc
Go to the documentation of this file.
1 //
22 // manage graphical render options
23 // e.g. print it in python for the rheolef_paraview.py script
24 //
25 // author: Pierre.Saramito@imag.fr
26 //
27 // date: 25 janv 2020
28 //
29 #include "rheolef/render_option.h"
30 namespace rheolef {
31 // ----------------------------------------------------------------------------
32 // option for scalar visualization with paraview
33 // ----------------------------------------------------------------------------
35  : showlabel(), stereo(), elevation(), iso(), cut(), grid(), fill(), volume(), view_2d(),
36  view_map(), high_order(), color(), gray(), black_and_white(), have_opacity_bug(),
37  n_isovalue(), n_isovalue_negative(), branch_size(1),
38  scale(), f_min(), f_max(), isovalue(),
39  resolution(),
40  xmin(), xmax(), origin(), normal(),
41  format(), mark(), label(), valued(), style()
42 {
43 }
44 std::ostream& operator << (std::ostream& py, const render_option& popt)
45 {
46  popt.put_paraview (py); return py;
47 }
48 void render_option::put_paraview (std::ostream& py) const
49 {
50  using namespace std;
51  if (format == "tiff") format = "tif";
52  if (format == "jpeg") format = "jpg";
53  if (black_and_white) fill = false;
54  string color_str = (color ? "color" : (gray ? "gray" : "black_and_white"));
55  if (isovalue != numeric_limits<Float>::max()) {
56  n_isovalue = 2; // draw {min, isovalue, max} when color : two bands
57  }
58  if (label == "") label = mark;
59  if (normal[0] == numeric_limits<Float>::max()) normal = point(1,0,0);
60  py << setprecision (numeric_limits<Float>::digits10)
61  << "#!/usr/bin/env paraview --script=" << endl
62  << "# This is a paraview script, automatically generated by rheolef." << endl
63  << endl
64  << "from paraview.simple import *" << endl
65  << "from paraview_rheolef import * # load rheolef specific functions" << endl
66  << endl
67  << "opt = { \\" << endl
68  << " 'format' : '" << format << "', \\" << endl
69  << " 'resolution' : [" << resolution[0] << "," << resolution[1] << "], \\" << endl
70  << " 'branch_size' : " << branch_size << ", \\" << endl
71  << " 'mark' : '" << mark << "', \\" << endl
72  << " 'label' : '" << label << "', \\" << endl
73  << " 'showlabel': " << showlabel << ", \\" << endl
74  << " 'axis' : 1, \\" << endl
75  << " 'color' : '" << color_str << "', \\" << endl
76  << " 'have_opacity_bug' : " << have_opacity_bug << ", \\" << endl
77  << " 'stereo' : " << stereo << ", \\" << endl
78  << " 'bbox' : [[" << xmin[0] << "," << xmin[1] << "," << xmin[2] << "],["
79  << xmax[0] << "," << xmax[1] << "," << xmax[2] << "]], \\" << endl
80  << " 'scale' : " << scale << ", \\" << endl
81  << " 'elevation' : " << elevation << ", \\" << endl
82  << " 'range' : [" << f_min << ", " << f_max << "], \\" << endl
83  << " 'iso' : " << iso << ", \\" << endl
84  << " 'isovalue' : " << isovalue << ", \\" << endl
85  << " 'n_isovalue' : " << n_isovalue << ", \\" << endl
86  << " 'n_isovalue_negative' : " << n_isovalue_negative << ", \\" << endl
87  << " 'cut' : " << cut << ", \\" << endl
88  << " 'origin' : " << python(origin) << ", \\" << endl
89  << " 'normal' : " << python(normal) << ", \\" << endl
90  << " 'grid' : " << grid << ", \\" << endl
91  << " 'fill' : " << fill << ", \\" << endl
92  << " 'volume' : " << volume << ", \\" << endl
93  << " 'view_1d' : 0, \\" << endl
94  << " 'view_2d' : " << view_2d << ", \\" << endl
95  << " 'view_map' : " << view_map << ", \\" << endl
96  << " 'high_order' : "<< high_order << ", \\" << endl
97  << " 'valued' : '"<< valued << "', \\" << endl
98  << " 'style' : '"<< style << "' \\" << endl
99  << "}" << endl
100  << endl
101  ;
102 }
103 std::string
104 render_option::python (const point& x, size_t d)
105 {
106  std::ostringstream os;
107  os << "(" << x[0];
108  for (size_t i = 1; i < d; i++)
109  os << ", " << x[i];
110  os << ")" << std::flush;
111  std::string buffer = os.str();
112  return buffer;
113 }
114 } // 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:44
rheolef::render_option::render_option
render_option()
Definition: render_option.cc:34
rheolef::render_option::color
bool color
Definition: render_option.h:44
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:44
rheolef::render_option::xmin
point xmin
Definition: render_option.h:49
rheolef::render_option::gray
bool gray
Definition: render_option.h:44
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:44
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:44
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