Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
WriteVtk.hpp
Go to the documentation of this file.
1 /**
2  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3  * storing and accessing finite element mesh data.
4  *
5  * Copyright 2004 Sandia Corporation. Under the terms of Contract
6  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7  * retains certain rights in this software.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  */
15 
16 #ifndef WRITE_VTK_HPP
17 #define WRITE_VTK_HPP
18 
19 #include <iosfwd>
20 
21 #include "moab/Forward.hpp"
22 #include "moab/WriterIface.hpp"
23 
24 namespace moab
25 {
26 
27 class WriteUtilIface;
28 
29 // class MB_DLL_EXPORT WriteVtk : public WriterIface
30 class WriteVtk : public WriterIface
31 {
32 
33  public:
34  //! Constructor
35  WriteVtk( Interface* impl );
36 
37  //! Destructor
38  virtual ~WriteVtk();
39 
40  static WriterIface* factory( Interface* );
41 
42  //! writes out a file
43  ErrorCode write_file( const char* file_name,
44  const bool overwrite,
45  const FileOptions& opts,
46  const EntityHandle* output_list,
47  const int num_sets,
48  const std::vector< std::string >& qa_list,
49  const Tag* tag_list = NULL,
50  int num_tags = 0,
51  int export_dimension = 3 );
52 
53  private:
54  //! Get entities to write, given set list passed to \ref write_file
55  ErrorCode gather_mesh( const EntityHandle* set_list, int num_sets, Range& nodes, Range& elems );
56 
57  //! Write 4-line VTK file header
58  ErrorCode write_header( std::ostream& stream );
59 
60  //! Write node coordinates
61  ErrorCode write_nodes( std::ostream& stream, const Range& nodes );
62 
63  //! Write element connectivity
64  ErrorCode write_elems( std::ostream& stream, const Range& nodes, const Range& elems );
65 
66  //! Write all tags on either the list of nodes or the list of elements
67  ErrorCode write_tags( std::ostream& stream, bool nodes, const Range& entities, const Tag* tag_list, int num_tags );
68 
69  //! Write the tad description for the passed tag and call the template
70  //! \ref write_tag function to write the tag data.
71  ErrorCode write_tag( std::ostream& stream, Tag tag, const Range& entities, const Range& tagged_entities );
72 
73  //! Write tag data
74  template < typename T >
75  ErrorCode write_tag( std::ostream& stream,
76  Tag tag,
77  const Range& entities,
78  const Range& tagged_entities,
79  const int );
80 
81  ErrorCode write_bit_tag( std::ostream& stream, Tag tag, const Range& entities, const Range& tagged_entities );
82  //! Write a list of values
83  template < typename T >
84  void write_data( std::ostream& stream, const std::vector< T >& data, unsigned vals_per_tag );
85 
88 
89  bool mStrict; // If true, do not write data that cannot fit in strict VTK file format.
90  int freeNodes;
92 };
93 
94 } // namespace moab
95 
96 #endif