~corrado-maurini/dolfin/tao

« back to all changes in this revision

Viewing changes to dolfin/plot/VTKPlottableMesh.h

  • Committer: corrado maurini
  • Date: 2012-12-18 12:16:08 UTC
  • mfrom: (6685.78.207 trunk)
  • Revision ID: corrado.maurini@upmc.fr-20121218121608-nk82ly9jgsld9u84
updating with trunk, fix uint in TAO solver and hacking the check for tao FindTAO.cmake

Show diffs side-by-side

added added

removed removed

Lines of Context:
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/>.
17
17
//
 
18
// Modified by Joachim B Haga 2012
 
19
//
18
20
// First added:  2012-06-20
19
 
// Last changed: 2012-06-26
 
21
// Last changed: 2012-09-13
20
22
 
21
23
#ifndef __VTK_PLOTTABLE_MESH_H
22
24
#define __VTK_PLOTTABLE_MESH_H
23
25
 
24
26
#ifdef HAS_VTK
25
27
 
26
 
#include <vtkUnstructuredGrid.h>
27
 
#include <vtkGeometryFilter.h>
 
28
#include <vtkSmartPointer.h>
 
29
 
 
30
#include <dolfin/common/types.h>
 
31
#include <dolfin/mesh/Mesh.h>
28
32
 
29
33
#include "GenericVTKPlottable.h"
30
34
 
 
35
class vtkActor2D;
 
36
class vtkActor3D;
 
37
class vtkAlgorithmOutput;
 
38
class vtkGeometryFilter;
 
39
class vtkIdFilter;
 
40
class vtkPointSetAlgorithm;
 
41
class vtkUnstructuredGrid;
 
42
class vtkFloatArray;
 
43
 
31
44
namespace dolfin
32
45
{
33
46
 
34
47
  class Mesh;
 
48
  class Parameters;
 
49
  class Variable;
 
50
  class VTKWindowOutputStage;
35
51
 
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
41
57
  {
42
58
  public:
43
59
 
 
60
    explicit VTKPlottableMesh(boost::shared_ptr<const Mesh> mesh, std::size_t entity_dim);
 
61
 
44
62
    explicit VTKPlottableMesh(boost::shared_ptr<const Mesh> mesh);
45
63
 
46
64
    //--- Implementation of the GenericVTKPlottable interface ---
47
65
 
 
66
    /// Additional parameters for VTKPlottableMesh
 
67
    virtual void modify_default_parameters(Parameters &parameters)
 
68
    {
 
69
      parameters["wireframe"] = true;
 
70
      parameters["scalarbar"] = false;
 
71
    }
 
72
 
48
73
    /// Initialize the parts of the pipeline that this class controls
49
 
    void init_pipeline();
 
74
    virtual void init_pipeline(const Parameters &parameters);
 
75
 
 
76
    /// Connect or reconnect to the output stage.
 
77
    virtual void connect_to_output(VTKWindowOutputStage& output);
50
78
 
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);
 
81
 
 
82
    /// Return whether this plottable is compatible with the variable
 
83
    virtual bool is_compatible(const Variable &var) const;
53
84
 
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]);
56
87
 
57
88
    /// Return geometric dimension
58
 
    virtual uint dim();
59
 
 
60
 
    /// Return data to visualize
61
 
    vtkSmartPointer<vtkAlgorithmOutput> get_output() const;
 
89
    virtual std::size_t dim() const;
62
90
 
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>);
 
93
 
 
94
    /// Get an actor for showing cell labels
 
95
    virtual vtkSmartPointer<vtkActor2D> get_cell_label_actor(vtkSmartPointer<vtkRenderer>);
 
96
 
 
97
    /// Get an actor for showing the mesh
 
98
    virtual vtkSmartPointer<vtkActor> get_mesh_actor();
65
99
 
66
100
  protected:
67
101
 
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;
 
104
 
 
105
    // Create label filter
 
106
    void build_id_filter();
 
107
 
 
108
    // Build the grid from mesh
 
109
    void build_grid_cells(vtkSmartPointer<vtkUnstructuredGrid> &grid, std::size_t entity_dim);
 
110
 
 
111
    // Remove values from an array if hide_above/hide_below are set
 
112
    void filter_scalars(vtkFloatArray *, const Parameters &);
 
113
 
 
114
    /// Set scalar values on the mesh
 
115
    template <class T>
 
116
    void setPointValues(std::size_t size, const T *indata, const Parameters &parameters);
 
117
 
 
118
    /// Set scalar values on the mesh
 
119
    template <class T>
 
120
    void setCellValues(std::size_t size, const T *indata, const Parameters &parameters);
 
121
 
 
122
    boost::shared_ptr<const Mesh> mesh() const;
 
123
 
 
124
    vtkSmartPointer<vtkUnstructuredGrid> grid() const;
 
125
 
 
126
    void insert_filter(vtkSmartPointer<vtkPointSetAlgorithm> filter);
 
127
 
 
128
  private:
 
129
 
 
130
    // The possibly lower-dimensional VTK grid constructed from the DOLFIN mesh
69
131
    vtkSmartPointer<vtkUnstructuredGrid> _grid;
70
132
 
 
133
    // The full-dimensional VTK grid constructed from the DOLFIN mesh
 
134
    vtkSmartPointer<vtkUnstructuredGrid> _full_grid;
 
135
 
71
136
    // The geometry filter
72
137
    vtkSmartPointer<vtkGeometryFilter> _geometryFilter;
73
138
 
74
139
    // The mesh to visualize
75
140
    boost::shared_ptr<const Mesh> _mesh;
76
141
 
77
 
    // The label actor
 
142
    // The label actors
78
143
    vtkSmartPointer<vtkActor2D> _vertexLabelActor;
 
144
    vtkSmartPointer<vtkActor2D> _cellLabelActor;
 
145
    vtkSmartPointer<vtkIdFilter> _idFilter;
 
146
 
 
147
    // The mesh actor
 
148
    vtkSmartPointer<vtkActor> _meshActor;
 
149
 
 
150
    // The dimension of the facets
 
151
    const std::size_t _entity_dim;
79
152
 
80
153
  };
81
154
 
 
155
  VTKPlottableMesh *CreateVTKPlottable(boost::shared_ptr<const Mesh> mesh);
82
156
}
83
157
 
84
158
#endif