Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
render_option.cc
Go to the documentation of this file.
1
21//
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"
30namespace 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}
44std::ostream& operator << (std::ostream& py, const render_option& popt)
45{
46 popt.put_paraview (py); return py;
47}
48void 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}
103std::string
104render_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
see the point page for the full documentation
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin gray
This file is part of Rheolef.
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition catchmark.h:99
details::field_expr_v2_nonlinear_terminal_function< details::normal_pseudo_function< Float > > normal()
normal: see the expression page for the full documentation
STL namespace.
void put_paraview(std::ostream &py) const
point_basic< size_t > resolution
static std::string python(const point &x, size_t d=3)