28#include "rheolef/field_expr.h"
29#include "rheolef/piola_util.h"
30#include "rheolef/rheostream.h"
31#include "rheolef/iorheo.h"
32#include "rheolef/iofem.h"
33#include "rheolef/interpolate.h"
34#include "rheolef/render_option.h"
43template <
class T> odiststream&
field_put_vtk (odiststream&,
const field_basic<T,sequential>&);
56 ostream& os = ops.
os();
62 popt.
fill = iorheo::getfill(os);
63 popt.
elevation = iorheo::getelevation(os);
64 popt.
color = iorheo::getcolor(os);
65 popt.
gray = iorheo::getgray(os);
67 popt.
showlabel = iorheo::getshowlabel(os);
68 popt.
stereo = iorheo::getstereo(os);
69 popt.
volume = iorheo::getvolume(os);
71 popt.
cut = iorheo::getcut(os);
72 popt.
grid = iorheo::getgrid(os);
73 popt.
format = iorheo::getimage_format(os);
74 popt.
mark = iorheo::getmark(os);
75 bool is_scalar = (popt.
valued ==
"scalar");
77 popt.
style = (popt.
valued ==
"vector") ? (iorheo::getvelocity(os) ?
"velocity" :
"deformation") :
"none";
78 popt.
scale = iorheo::getvectorscale(os);
79 popt.
origin = iofem::getorigin(os);
80 popt.
normal = iofem::getnormal(os);
84 popt.
isovalue = iorheo::getisovalue(os);
85 popt.
label = iorheo::getlabel(os);
88 size_type map_dim = omega.map_dimension();
91#if (_RHEOLEF_PARAVIEW_VERSION_MAJOR >= 5) && (_RHEOLEF_PARAVIEW_VERSION_MINOR >= 5)
97#if (_RHEOLEF_PARAVIEW_VERSION_MAJOR == 5) && (_RHEOLEF_PARAVIEW_VERSION_MINOR == 7)
106 if (popt.
valued ==
"scalar") {
119 bool verbose = iorheo::getverbose(os);
120 bool clean = iorheo::getclean(os);
121 bool execute = iorheo::getexecute(os);
122 string basename = iorheo::getbasename(os);
123 string outfile_fmt =
"";
125 if (!clean) tmp =
"";
127 string filename = tmp+basename +
".vtk";
128 filelist = filelist +
" " + filename;
129 ofstream vtk_os (filename.c_str());
131 if (verbose) clog <<
"! file \"" << filename <<
"\" created.\n";
137 std::string py_name = filename = tmp+basename +
".py";
138 filelist = filelist +
" " + filename;
139 ofstream py (filename.c_str());
140 if (verbose) clog <<
"! file \"" << filename <<
"\" created.\n";
145 <<
"paraview_field_" << popt.
valued <<
"(paraview, \"" << tmp+basename <<
"\", opt)" << endl
155 string prog = (popt.
format ==
"") ?
"paraview --script=" :
"pvbatch --use-offscreen-rendering ";
157 if (popt.
format !=
"") command =
"DISPLAY=:0.0 " + command;
158 if (popt.
stereo && popt.
format ==
"") command = command +
" --stereo";
159 if (verbose) clog <<
"! " << command << endl;
160 status = system (command.c_str());
166 command =
"/bin/rm -f " + filelist;
167 if (verbose) clog <<
"! " << command << endl;
168 status = system (command.c_str());
175template <
class T> idiststream&
geo_get_vtk (idiststream&, geo_basic<T,sequential>&);
178field_basic<T,sequential>
192 ostream& os = std::cout;
193 bool verbose = iorheo::getverbose(os);
194 bool clean = iorheo::getclean(os);
195 bool execute = iorheo::getexecute(os);
196 string basename = iorheo::getbasename(os);
198 if (!clean) tmp =
"";
203 string vtk_name = tmp+basename +
".vtk";
204 filelist = filelist +
" " + vtk_name;
205 ofstream vtk_os (vtk_name.c_str());
207 if (verbose) clog <<
"! file \"" << vtk_name <<
"\" created.\n";
216 string py_name = tmp+basename +
"-cut.py";
217 string vtk_cut_name = tmp+basename +
"-cut.vtk";
218 filelist = filelist +
" " + py_name +
" " + vtk_cut_name;
219 ofstream py (py_name.c_str());
220 if (verbose) clog <<
"! file \"" << py_name <<
"\" created.\n";
221 py << setprecision(numeric_limits<T>::digits10)
222 <<
"from paraview.simple import *" << endl
223 <<
"reader = LegacyVTKReader(FileNames=['" << vtk_name <<
"'])" << endl
224 <<
"slice = Slice(SliceType=\"Plane\")" << endl
225 <<
"slice.SliceOffsetValues = [0.0]" << endl
228 <<
"writer = paraview.simple.CreateWriter(\"" << vtk_cut_name <<
"\", slice)" << endl
229 <<
"writer.FileType = 'Ascii'" << endl
230 <<
"writer.UpdatePipeline()" << endl
239 if (verbose) clog <<
"! " << command << endl;
240 status = system (command.c_str());
244 ifstream vtk_polydata (vtk_cut_name.c_str());
245 check_macro (vtk_polydata,
"field: vtk polydata file \"" << vtk_cut_name <<
"\" not found.");
246 if (verbose) clog <<
"! load `" << vtk_cut_name <<
"'." << endl;
250 gamma_cut.set_name (basename +
"-cut");
251 check_macro (gamma_cut.n_node() > 0,
"empty mesh & plane intersection: HINT check normal and origin");
256 command =
"/bin/rm -f " + filelist;
257 if (verbose) clog <<
"! " << command << endl;
258 status = system (command.c_str());
268 bool use_projection =
true;
269 if (use_projection) {
270 switch (uh.
get_geo().dimension()) {
273 gamma_cut.set_dimension (1);
276 for (
size_type i = 0, n = node.size(); i < n; i++) {
279 gamma_cut.set_nodes (node);
283 gamma_cut.set_dimension (2);
290 for (
size_type i = 0, n = node.size(); i < n; i++) {
293 gamma_cut.set_nodes (node);
307 bool founded =
false;
308 while (vtk_polydata.good()) {
309 vtk_polydata >> data_type;
310 if ((data_type ==
"POINT_DATA") ||
311 (data_type ==
"CELL_DATA" )) {
315 check_macro (data_type ==
"POINT_DATA" || data_type ==
"CELL_DATA",
316 "paraview_plane_cut: unexpected vtk polydata file");
317 scatch (vtk_polydata,
"default");
318 string approx = (data_type ==
"POINT_DATA") ?
"P1" :
"P0";
321 u_cut.
set_u().get_values (ips_vtk_polydata);
327template <
class T> idiststream&
geo_get_vtk (idiststream&, geo_basic<T,sequential>&);
330geo_basic<T,sequential>
341 ostream& os = std::cout;
342 bool verbose = iorheo::getverbose(os);
343 bool clean = iorheo::getclean(os);
344 bool execute = iorheo::getexecute(os);
345 T isovalue = iorheo::getisovalue(os);
346 string basename = iorheo::getbasename(os);
348 if (!clean) tmp =
"";
353 string vtk_name = tmp+basename +
".vtk";
354 filelist = filelist +
" " + vtk_name;
355 ofstream vtk_os (vtk_name.c_str());
357 if (verbose) clog <<
"! file \"" << vtk_name <<
"\" created.\n";
366 string py_name = tmp+basename +
"-iso.py";
367 string vtk_iso_name = tmp+basename +
"-iso.vtk";
368 filelist = filelist +
" " + py_name +
" " + vtk_iso_name;
369 ofstream py (py_name.c_str());
370 if (verbose) clog <<
"! file \"" << py_name <<
"\" created.\n";
371 py << setprecision(numeric_limits<T>::digits10)
372 <<
"from paraview.simple import *" << endl
373 <<
"reader = LegacyVTKReader(FileNames=['" << vtk_name <<
"'])" << endl
374 <<
"iso_surface = Contour(PointMergeMethod=\"Uniform Binning\")" << endl
375 <<
"iso_surface.ContourBy = ['POINTS', 'scalar']" << endl
376 <<
"iso_surface.Isosurfaces = [" << isovalue <<
"]" << endl
377 <<
"writer = paraview.simple.CreateWriter(\"" << vtk_iso_name <<
"\", iso_surface)" << endl
378 <<
"writer.FileType = 'Ascii'" << endl
379 <<
"writer.UpdatePipeline()" << endl
388 if (verbose) clog <<
"! " << command << endl;
389 status = system (command.c_str());
393 ifstream vtk_polydata (vtk_iso_name.c_str());
394 check_macro (vtk_polydata,
"field: vtk polydata file \"" << vtk_iso_name <<
"\" not found.");
395 if (verbose) clog <<
"! load `" << vtk_iso_name <<
"'." << endl;
399 gamma_iso.set_name (basename +
"-iso");
400 gamma_iso.set_dimension (uh.
get_geo().dimension());
401 check_macro (gamma_iso.n_node() > 0,
"empty mesh & plane intersection: HINT check normal and origin");
406 command =
"/bin/rm -f " + filelist;
407 if (verbose) clog <<
"! " << command << endl;
408 status = system (command.c_str());
415#define _RHEOLEF_instanciation(T) \
416template odiststream& \
417visu_vtk_paraview<Float> ( \
419 const field_basic<Float,sequential>&); \
420template field_basic<Float,sequential> \
421paraview_plane_cut ( \
422 const field_basic<Float,sequential>&, \
423 const point_basic<Float>&, \
424 const point_basic<Float>&); \
425template geo_basic<Float,sequential> \
426paraview_extract_isosurface ( \
427 const field_basic<Float,sequential>&);
430#undef _RHEOLEF_instanciation
#define _RHEOLEF_instanciation(T, M, A)
field::size_type size_type
see the Float page for the full documentation
see the point page for the full documentation
see the disarray page for the full documentation
const geo_type & get_geo() const
const space_type & get_space() const
typename float_traits< T >::type float_type
generic mesh with rerefence counting
idiststream: see the diststream page for the full documentation
odiststream: see the diststream page for the full documentation
#define _RHEOLEF_PKGDATADIR
#define error_macro(message)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format vtk
This file is part of Rheolef.
geo_basic< T, sequential > paraview_extract_isosurface(const field_basic< T, sequential > &uh)
odiststream & visu_vtk_paraview(odiststream &, const field_basic< T, sequential > &)
point_basic< T > vect(const point_basic< T > &v, const point_basic< T > &w)
bool scatch(std::istream &in, const std::string &ch, bool full_match=true)
scatch: see the rheostream page for the full documentation
std::string get_tmpdir()
get_tmpdir: see the rheostream page for the full documentation
idiststream & geo_get_vtk(idiststream &ips, geo_basic< T, sequential > &omega)
field_basic< T, sequential > paraview_plane_cut(const field_basic< T, sequential > &uh, const point_basic< T > &origin, const point_basic< T > &normal)
details::field_expr_v2_nonlinear_terminal_function< details::normal_pseudo_function< Float > > normal()
normal: see the expression page for the full documentation
odiststream & field_put_vtk(odiststream &, const field_basic< T, sequential > &, std::string, bool)
rheolef::std enable_if ::type dot const Expr1 expr1, const Expr2 expr2 dot(const Expr1 &expr1, const Expr2 &expr2)
field_basic< T, M > interpolate(const space_basic< T, M > &V2h, const field_basic< T, M > &u1h)
see the interpolate page for the full documentation
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
size_t n_isovalue_negative
point_basic< size_t > resolution
static std::string python(const point &x, size_t d=3)