15
15
// You should have received a copy of the GNU Lesser General Public License
16
16
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
18
// Modified by Joachim B Haga 2012
18
20
// First added: 2012-06-20
19
// Last changed: 2012-06-26
21
// Last changed: 2012-09-13
21
23
#ifndef __VTK_PLOTTABLE_MESH_H
22
24
#define __VTK_PLOTTABLE_MESH_H
26
#include <vtkUnstructuredGrid.h>
27
#include <vtkGeometryFilter.h>
28
#include <vtkSmartPointer.h>
30
#include <dolfin/common/types.h>
31
#include <dolfin/mesh/Mesh.h>
29
33
#include "GenericVTKPlottable.h"
37
class vtkAlgorithmOutput;
38
class vtkGeometryFilter;
40
class vtkPointSetAlgorithm;
41
class vtkUnstructuredGrid;
50
class VTKWindowOutputStage;
36
52
/// Data wrapper class for plotting meshes. It also acts as a superclass
37
53
/// for the other data wrapper classes, as all kinds of plottable data
60
explicit VTKPlottableMesh(boost::shared_ptr<const Mesh> mesh, std::size_t entity_dim);
44
62
explicit VTKPlottableMesh(boost::shared_ptr<const Mesh> mesh);
46
64
//--- Implementation of the GenericVTKPlottable interface ---
66
/// Additional parameters for VTKPlottableMesh
67
virtual void modify_default_parameters(Parameters ¶meters)
69
parameters["wireframe"] = true;
70
parameters["scalarbar"] = false;
48
73
/// Initialize the parts of the pipeline that this class controls
74
virtual void init_pipeline(const Parameters ¶meters);
76
/// Connect or reconnect to the output stage.
77
virtual void connect_to_output(VTKWindowOutputStage& output);
51
79
/// Update the plottable data
52
void update(const Parameters& parameters, int frame_counter);
80
virtual void update(boost::shared_ptr<const Variable> var, const Parameters& parameters, int frame_counter);
82
/// Return whether this plottable is compatible with the variable
83
virtual bool is_compatible(const Variable &var) const;
54
85
/// Update the scalar range of the plottable data
55
void update_range(double range[2]);
86
virtual void update_range(double range[2]);
57
88
/// Return geometric dimension
60
/// Return data to visualize
61
vtkSmartPointer<vtkAlgorithmOutput> get_output() const;
89
virtual std::size_t dim() const;
63
91
/// Get an actor for showing vertex labels
64
vtkSmartPointer<vtkActor2D> get_vertex_label_actor();
92
virtual vtkSmartPointer<vtkActor2D> get_vertex_label_actor(vtkSmartPointer<vtkRenderer>);
94
/// Get an actor for showing cell labels
95
virtual vtkSmartPointer<vtkActor2D> get_cell_label_actor(vtkSmartPointer<vtkRenderer>);
97
/// Get an actor for showing the mesh
98
virtual vtkSmartPointer<vtkActor> get_mesh_actor();
68
// The VTK grid constructed from the DOLFIN mesh
102
/// Get the output port. Called from connect_to_output.
103
virtual vtkSmartPointer<vtkAlgorithmOutput> get_output() const;
105
// Create label filter
106
void build_id_filter();
108
// Build the grid from mesh
109
void build_grid_cells(vtkSmartPointer<vtkUnstructuredGrid> &grid, std::size_t entity_dim);
111
// Remove values from an array if hide_above/hide_below are set
112
void filter_scalars(vtkFloatArray *, const Parameters &);
114
/// Set scalar values on the mesh
116
void setPointValues(std::size_t size, const T *indata, const Parameters ¶meters);
118
/// Set scalar values on the mesh
120
void setCellValues(std::size_t size, const T *indata, const Parameters ¶meters);
122
boost::shared_ptr<const Mesh> mesh() const;
124
vtkSmartPointer<vtkUnstructuredGrid> grid() const;
126
void insert_filter(vtkSmartPointer<vtkPointSetAlgorithm> filter);
130
// The possibly lower-dimensional VTK grid constructed from the DOLFIN mesh
69
131
vtkSmartPointer<vtkUnstructuredGrid> _grid;
133
// The full-dimensional VTK grid constructed from the DOLFIN mesh
134
vtkSmartPointer<vtkUnstructuredGrid> _full_grid;
71
136
// The geometry filter
72
137
vtkSmartPointer<vtkGeometryFilter> _geometryFilter;
74
139
// The mesh to visualize
75
140
boost::shared_ptr<const Mesh> _mesh;
78
143
vtkSmartPointer<vtkActor2D> _vertexLabelActor;
144
vtkSmartPointer<vtkActor2D> _cellLabelActor;
145
vtkSmartPointer<vtkIdFilter> _idFilter;
148
vtkSmartPointer<vtkActor> _meshActor;
150
// The dimension of the facets
151
const std::size_t _entity_dim;
155
VTKPlottableMesh *CreateVTKPlottable(boost::shared_ptr<const Mesh> mesh);