MOAB: Mesh Oriented datABase  (version 5.2.1)
WriteVtk.hpp
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  *
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain rights in this software.
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  */
00015 
00016 #ifndef WRITE_VTK_HPP
00017 #define WRITE_VTK_HPP
00018 
00019 #include <iosfwd>
00020 
00021 #include "moab/Forward.hpp"
00022 #include "moab/WriterIface.hpp"
00023 
00024 namespace moab
00025 {
00026 
00027 class WriteUtilIface;
00028 
00029 // class MB_DLL_EXPORT WriteVtk : public WriterIface
00030 class WriteVtk : public WriterIface
00031 {
00032 
00033   public:
00034     //! Constructor
00035     WriteVtk( Interface* impl );
00036 
00037     //! Destructor
00038     virtual ~WriteVtk();
00039 
00040     static WriterIface* factory( Interface* );
00041 
00042     //! writes out a file
00043     ErrorCode write_file( const char* file_name, const bool overwrite, const FileOptions& opts,
00044                           const EntityHandle* output_list, const int num_sets,
00045                           const std::vector< std::string >& qa_list, const Tag* tag_list = NULL, int num_tags = 0,
00046                           int export_dimension = 3 );
00047 
00048   private:
00049     //! Get entities to write, given set list passed to \ref write_file
00050     ErrorCode gather_mesh( const EntityHandle* set_list, int num_sets, Range& nodes, Range& elems );
00051 
00052     //! Write 4-line VTK file header
00053     ErrorCode write_header( std::ostream& stream );
00054 
00055     //! Write node coordinates
00056     ErrorCode write_nodes( std::ostream& stream, const Range& nodes );
00057 
00058     //! Write element connectivity
00059     ErrorCode write_elems( std::ostream& stream, const Range& nodes, const Range& elems );
00060 
00061     //! Write all tags on either the list of nodes or the list of elements
00062     ErrorCode write_tags( std::ostream& stream, bool nodes, const Range& entities, const Tag* tag_list, int num_tags );
00063 
00064     //! Write the tad description for the passed tag and call the template
00065     //! \ref write_tag function to write the tag data.
00066     ErrorCode write_tag( std::ostream& stream, Tag tag, const Range& entities, const Range& tagged_entities );
00067 
00068     //! Write tag data
00069     template < typename T >
00070     ErrorCode write_tag( std::ostream& stream, Tag tag, const Range& entities, const Range& tagged_entities,
00071                          const int );
00072 
00073     ErrorCode write_bit_tag( std::ostream& stream, Tag tag, const Range& entities, const Range& tagged_entities );
00074     //! Write a list of values
00075     template < typename T >
00076     void write_data( std::ostream& stream, const std::vector< T >& data, unsigned vals_per_tag );
00077 
00078     Interface* mbImpl;
00079     WriteUtilIface* writeTool;
00080 
00081     bool mStrict;  // If true, do not write data that cannot fit in strict VTK file format.
00082     int freeNodes;
00083     bool createOneNodeCells;
00084 };
00085 
00086 }  // namespace moab
00087 
00088 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines