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 17 #ifndef WRITE_VTK_HPP 18 #define WRITE_VTK_HPP 19 20 #include <iosfwd> 21 22 #include "moab/Forward.hpp" 23 #include "moab/WriterIface.hpp" 24 25 namespace moab { 26 27 class WriteUtilIface; 28 29 //class MB_DLL_EXPORT WriteVtk : public WriterIface 30 class WriteVtk : public WriterIface 31 { 32 33 public: 34 35 //! Constructor 36 WriteVtk(Interface *impl); 37 38 //! Destructor 39 virtual ~WriteVtk(); 40 41 static WriterIface* factory( Interface* ); 42 43 //! writes out a file 44 ErrorCode write_file(const char *file_name, 45 const bool overwrite, 46 const FileOptions& opts, 47 const EntityHandle *output_list, 48 const int num_sets, 49 const std::vector<std::string>& qa_list, 50 const Tag* tag_list = NULL, 51 int num_tags = 0, 52 int export_dimension = 3); 53 54 private: 55 56 //! Get entities to write, given set list passed to \ref write_file 57 ErrorCode gather_mesh( const EntityHandle* set_list, 58 int num_sets, 59 Range& nodes, 60 Range& elems ); 61 62 //! Write 4-line VTK file header 63 ErrorCode write_header( std::ostream& stream ); 64 65 //! Write node coordinates 66 ErrorCode write_nodes( std::ostream& stream, const Range& nodes ); 67 68 //! Write element connectivity 69 ErrorCode write_elems( std::ostream& stream, const Range& nodes, const Range& elems ); 70 71 //! Write all tags on either the list of nodes or the list of elements 72 ErrorCode write_tags( std::ostream& stream, bool nodes, const Range& entities, 73 const Tag* tag_list, int num_tags ); 74 75 //! Write the tad description for the passed tag and call the template 76 //! \ref write_tag function to write the tag data. 77 ErrorCode write_tag( std::ostream& stream, Tag tag, const Range& entities, const Range& tagged_entities ); 78 79 //! Write tag data 80 template <typename T> 81 ErrorCode write_tag( std::ostream& stream, Tag tag, const Range& entities, const Range& tagged_entities, 82 const int); 83 84 ErrorCode write_bit_tag( std::ostream& stream, Tag tag, const Range& entities, const Range& tagged_entities ); 85 //! Write a list of values 86 template <typename T> 87 void write_data( std::ostream& stream, const std::vector<T>& data, unsigned vals_per_tag ); 88 89 Interface* mbImpl; 90 WriteUtilIface* writeTool; 91 92 bool mStrict; // If true, do not write data that cannot fit in strict VTK file format. 93 int freeNodes; 94 bool createOneNodeCells; 95 96 }; 97 98 } // namespace moab 99 100 #endif 101