DOLFIN
DOLFIN C++ interface
X3DFile.h
1 // Copyright (C) 2013 Chris Richardson
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // First added: 2012-03-05
19 // Last changed: 2013-05-10
20 
21 #ifndef __X3D_FILE_H
22 #define __X3D_FILE_H
23 
24 #include "GenericFile.h"
25 
26 namespace pugi
27 {
28  class xml_document;
29 }
30 
31 namespace dolfin
32 {
33 
40 
41  class X3DFile : public GenericFile
42  {
43  public:
44 
46  explicit X3DFile(const std::string filename);
47 
49  ~X3DFile();
50 
53  void write(const Mesh& mesh);
54 
57  void write(const MeshFunction<std::size_t>& meshfunction);
58 
61  void write(const Function& function);
62 
63  private:
64 
65  // Get mesh dimensions and viewpoint distance
66  std::vector<double> mesh_min_max(const Mesh& mesh) const;
67 
68  // Get list of vertex indices which are on surface
69  std::vector<std::size_t> vertex_index(const Mesh& mesh) const;
70 
71  // Output mesh vertices to XML
72  void write_vertices(pugi::xml_document& xml_doc, const Mesh& mesh,
73  const std::vector<std::size_t> vecindex);
74 
75  // XML header output
76  void output_xml_header(pugi::xml_document& xml_doc,
77  const std::vector<double>& xpos);
78 
79  // Write out surface mesh to file
80  void write_meshfunction(const MeshFunction<std::size_t>& meshfunction);
81 
82  // Get a string representing a color palette
83  std::string color_palette(const int pal) const;
84 
85  // Whether in Face or Edge mode - should either be
86  // "IndexedFaceSet" or "IndexedLineSet"
87  const std::string facet_type;
88 
89  };
90 
91 }
92 
93 #endif
Definition: adapt.h:29
Base class for file I/O objects.
Definition: GenericFile.h:44
Definition: Function.h:65
Definition: X3DFile.h:41
Definition: VTKFile.h:27
Definition: Mesh.h:82