Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
ReadVtk.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 READ_VTK_HPP
17 #define READ_VTK_HPP
18 
19 #include "moab/Forward.hpp"
20 #include "moab/ReaderIface.hpp"
21 
22 #include <string>
23 
24 namespace moab
25 {
26 
27 class ReadUtilIface;
28 class FileTokenizer;
29 
30 class ReadVtk : public ReaderIface
31 {
32 
33  public:
34  static ReaderIface* factory( Interface* );
35 
36  //! load a file
37  ErrorCode load_file( const char* file_name,
38  const EntityHandle* file_set,
39  const FileOptions& opts,
40  const SubsetList* subset_list = 0,
41  const Tag* file_id_tag = 0 );
42 
43  ErrorCode read_tag_values( const char* file_name,
44  const char* tag_name,
45  const FileOptions& opts,
46  std::vector< int >& tag_values_out,
47  const SubsetList* subset_list = 0 );
48 
49  //! Constructor
50  ReadVtk( Interface* impl = NULL );
51 
52  //! Destructor
53  virtual ~ReadVtk();
54 
55  protected:
56  ErrorCode allocate_vertices( long num_vtx,
57  EntityHandle& start_handle_out,
58  double*& x_coord_array_out,
59  double*& y_coord_array_out,
60  double*& z_coord_array_out );
61 
62  ErrorCode read_vertices( FileTokenizer& tokens, long num_verts, EntityHandle& start_handle_out );
63 
64  ErrorCode allocate_elements( long num_elements,
65  int vert_per_element,
66  EntityType type,
67  EntityHandle& start_handle_out,
68  EntityHandle*& conn_array_out,
69  std::vector< Range >& append_to_this );
70 
71  ErrorCode vtk_read_dataset( FileTokenizer& tokens, Range& vertex_list, std::vector< Range >& element_list );
72 
73  ErrorCode vtk_read_structured_points( FileTokenizer& tokens, Range& vertex_list, std::vector< Range >& elem_list );
74 
75  ErrorCode vtk_read_structured_grid( FileTokenizer& tokens, Range& vertex_list, std::vector< Range >& elem_list );
76 
77  ErrorCode vtk_read_rectilinear_grid( FileTokenizer& tokens, Range& vertex_list, std::vector< Range >& elem_list );
78 
79  ErrorCode vtk_read_polydata( FileTokenizer& tokens, Range& vertex_list, std::vector< Range >& elem_list );
80 
81  ErrorCode vtk_read_polygons( FileTokenizer& tokens, EntityHandle first_vtx, std::vector< Range >& elem_list );
82 
83  ErrorCode vtk_read_unstructured_grid( FileTokenizer& tokens, Range& vertex_list, std::vector< Range >& elem_list );
84 
85  ErrorCode vtk_create_structured_elems( const long* dims, EntityHandle first_vtx, std::vector< Range >& elem_list );
86 
88 
89  ErrorCode vtk_read_attrib_data( FileTokenizer& tokens, std::vector< Range >& entities );
90 
92  int type,
93  size_t per_elem,
94  std::vector< Range >& entities,
95  const char* name );
96 
97  ErrorCode vtk_read_scalar_attrib( FileTokenizer& tokens, std::vector< Range >& entities, const char* name );
98 
99  ErrorCode vtk_read_color_attrib( FileTokenizer& tokens, std::vector< Range >& entities, const char* name );
100 
101  ErrorCode vtk_read_vector_attrib( FileTokenizer& tokens, std::vector< Range >& entities, const char* name );
102 
103  ErrorCode vtk_read_texture_attrib( FileTokenizer& tokens, std::vector< Range >& entities, const char* name );
104 
105  ErrorCode vtk_read_tensor_attrib( FileTokenizer& tokens, std::vector< Range >& entities, const char* name );
106 
107  ErrorCode vtk_read_field_attrib( FileTokenizer& tokens, std::vector< Range >& entities, const char* name );
108 
109  ErrorCode store_file_ids( Tag tag, const Range& vertices, const std::vector< Range >& elements );
110 
111  private:
113 
114  //------------member variables ------------//
115 
116  //! interface instance
118 
119  //! A field which, if present and having a single integer for storage, should be used to
120  //! partition the mesh by range. Defaults to MATERIAL_SET_TAG_NAME
121  std::string mPartitionTagName;
122 };
123 
124 } // namespace moab
125 
126 #endif