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"
43 template <
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");
76 if (popt.
mark ==
"") popt.
mark =
"scalar";
77 if (popt.
mark !=
"" && !is_scalar) popt.
mark =
"|"+popt.
mark +
"|";
78 popt.
style = (popt.
valued ==
"vector") ? (iorheo::getvelocity(os) ?
"velocity" :
"deformation") :
"none";
79 popt.
scale = iorheo::getvectorscale(os);
80 popt.
origin = iofem::getorigin(os);
81 popt.
normal = iofem::getnormal(os);
85 popt.
isovalue = iorheo::getisovalue(os);
86 popt.
label = iorheo::getlabel(os);
92 #if (_RHEOLEF_PARAVIEW_VERSION_MAJOR >= 5) && (_RHEOLEF_PARAVIEW_VERSION_MINOR >= 5)
98 #if (_RHEOLEF_PARAVIEW_VERSION_MAJOR == 5) && (_RHEOLEF_PARAVIEW_VERSION_MINOR == 7)
107 if (popt.
valued ==
"scalar") {
120 bool verbose = iorheo::getverbose(os);
121 bool clean = iorheo::getclean(os);
122 bool execute = iorheo::getexecute(os);
123 string basename = iorheo::getbasename(os);
124 string outfile_fmt =
"";
129 filelist = filelist +
" " + filename;
130 ofstream vtk_os (filename.c_str());
132 if (
verbose) clog <<
"! file \"" << filename <<
"\" created.\n";
138 std::string py_name = filename =
tmp+
basename +
".py";
139 filelist = filelist +
" " + filename;
140 ofstream py (filename.c_str());
141 if (
verbose) clog <<
"! file \"" << filename <<
"\" created.\n";
146 <<
"paraview_field_" << popt.
valued <<
"(paraview, \"" <<
tmp+
basename <<
"\", opt)" << endl
156 string prog = (popt.
format ==
"") ?
"paraview --script=" :
"pvbatch --use-offscreen-rendering ";
167 command =
"/bin/rm -f " + filelist;
176 template <
class T> idiststream&
geo_get_vtk (idiststream&, geo_basic<T,sequential>&);
179 field_basic<T,sequential>
193 ostream& os = std::cout;
194 bool verbose = iorheo::getverbose(os);
195 bool clean = iorheo::getclean(os);
196 bool execute = iorheo::getexecute(os);
197 string basename = iorheo::getbasename(os);
205 filelist = filelist +
" " + vtk_name;
206 ofstream vtk_os (vtk_name.c_str());
208 if (
verbose) clog <<
"! file \"" << vtk_name <<
"\" created.\n";
219 filelist = filelist +
" " + py_name +
" " + vtk_cut_name;
220 ofstream py (py_name.c_str());
221 if (
verbose) clog <<
"! file \"" << py_name <<
"\" created.\n";
222 py << setprecision(numeric_limits<T>::digits10)
223 <<
"from paraview.simple import *" << endl
224 <<
"reader = LegacyVTKReader(FileNames=['" << vtk_name <<
"'])" << endl
225 <<
"slice = Slice(SliceType=\"Plane\")" << endl
226 <<
"slice.SliceOffsetValues = [0.0]" << endl
229 <<
"writer = paraview.simple.CreateWriter(\"" << vtk_cut_name <<
"\", slice)" << endl
230 <<
"writer.FileType = 'Ascii'" << endl
231 <<
"writer.UpdatePipeline()" << endl
245 ifstream vtk_polydata (vtk_cut_name.c_str());
246 check_macro (vtk_polydata,
"field: vtk polydata file \"" << vtk_cut_name <<
"\" not found.");
247 if (
verbose) clog <<
"! load `" << vtk_cut_name <<
"'." << endl;
248 idiststream ips_vtk_polydata (vtk_polydata);
252 check_macro (gamma_cut.
n_node() > 0,
"empty mesh & plane intersection: HINT check normal and origin");
257 command =
"/bin/rm -f " + filelist;
269 bool use_projection =
true;
270 if (use_projection) {
271 switch (uh.
get_geo().dimension()) {
277 for (
size_type i = 0,
n = node.size(); i <
n; i++) {
291 for (
size_type i = 0,
n = node.size(); i <
n; i++) {
309 vtk_polydata >> data_type;
310 if ((data_type ==
"POINT_DATA") ||
311 (data_type ==
"CELL_DATA" )) {
315 scatch (vtk_polydata,
"default");
316 string approx = (data_type ==
"POINT_DATA") ?
"P1" :
"P0";
319 u_cut.
set_u().get_values (ips_vtk_polydata);
325 template <
class T> idiststream&
geo_get_vtk (idiststream&, geo_basic<T,sequential>&);
328 geo_basic<T,sequential>
339 ostream& os = std::cout;
340 bool verbose = iorheo::getverbose(os);
341 bool clean = iorheo::getclean(os);
342 bool execute = iorheo::getexecute(os);
343 T isovalue = iorheo::getisovalue(os);
344 string basename = iorheo::getbasename(os);
352 filelist = filelist +
" " + vtk_name;
353 ofstream vtk_os (vtk_name.c_str());
355 if (
verbose) clog <<
"! file \"" << vtk_name <<
"\" created.\n";
366 filelist = filelist +
" " + py_name +
" " + vtk_iso_name;
367 ofstream py (py_name.c_str());
368 if (
verbose) clog <<
"! file \"" << py_name <<
"\" created.\n";
369 py << setprecision(numeric_limits<T>::digits10)
370 <<
"from paraview.simple import *" << endl
371 <<
"reader = LegacyVTKReader(FileNames=['" << vtk_name <<
"'])" << endl
372 <<
"iso_surface = Contour(PointMergeMethod=\"Uniform Binning\")" << endl
373 <<
"iso_surface.ContourBy = ['POINTS', 'scalar']" << endl
374 <<
"iso_surface.Isosurfaces = [" << isovalue <<
"]" << endl
375 <<
"writer = paraview.simple.CreateWriter(\"" << vtk_iso_name <<
"\", iso_surface)" << endl
376 <<
"writer.FileType = 'Ascii'" << endl
377 <<
"writer.UpdatePipeline()" << endl
391 ifstream vtk_polydata (vtk_iso_name.c_str());
392 check_macro (vtk_polydata,
"field: vtk polydata file \"" << vtk_iso_name <<
"\" not found.");
393 if (
verbose) clog <<
"! load `" << vtk_iso_name <<
"'." << endl;
394 idiststream ips_vtk_polydata (vtk_polydata);
399 check_macro (gamma_iso.
n_node() > 0,
"empty mesh & plane intersection: HINT check normal and origin");
404 command =
"/bin/rm -f " + filelist;
413 #define _RHEOLEF_instanciation(T) \
414 template odiststream& \
415 visu_vtk_paraview<Float> ( \
417 const field_basic<Float,sequential>&); \
418 template field_basic<Float,sequential> \
419 paraview_plane_cut ( \
420 const field_basic<Float,sequential>&, \
421 const point_basic<Float>&, \
422 const point_basic<Float>&); \
423 template geo_basic<Float,sequential> \
424 paraview_extract_isosurface ( \
425 const field_basic<Float,sequential>&);
428 #undef _RHEOLEF_instanciation
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 space_type & get_space() const
const geo_type & get_geo() const
typename float_traits< T >::type float_type
void set_dimension(size_type dim)
void set_name(std::string name)
void set_nodes(const disarray< node_type, sequential > &x)
const disarray< node_type, sequential > & get_nodes() const
generic mesh with rerefence counting
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)")
#define _RHEOLEF_instanciation(T)
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
rheolef::details::is_vec dot
This file is part of Rheolef.
geo_basic< T, sequential > paraview_extract_isosurface(const field_basic< T, sequential > &uh)
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
bool scatch(std::istream &in, const std::string &ch, bool full_match=true)
scatch: see the rheostream page for the full documentation
field_basic< T, sequential > paraview_plane_cut(const field_basic< T, sequential > &uh, const point_basic< T > &origin, const point_basic< T > &normal)
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
point_basic< T > vect(const point_basic< T > &v, const point_basic< T > &w)
std::string itos(std::string::size_type i)
itos: see the rheostream page for the full documentation
odiststream & field_put_vtk(odiststream &, const field_basic< T, sequential > &, std::string, bool)
odiststream & visu_vtk_paraview(odiststream &, const field_basic< T, sequential > &)
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)
details::field_expr_v2_nonlinear_terminal_function< details::normal_pseudo_function< Float > > normal()
normal: see the expression page for the full documentation
std::string python(const point_basic< T > &x, size_t d=3)
size_t n_isovalue_negative
point_basic< size_t > resolution