-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
vtk_to_volume_mesh.h
54 lines (40 loc) · 1.47 KB
/
vtk_to_volume_mesh.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#include <string>
#include "drake/geometry/proximity/volume_mesh.h"
namespace drake {
namespace geometry {
namespace internal {
/* @name Import tetrahedral volume meshes from VTK files for deformable
geometries. These internal functions import VolumeMesh from a subset of VTK
files (legacy, serial, ASCII, UNSTRUCTURED_GRID). They only support a limited
number of tags and ignore the rest. The file format is described in:
https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf
*/
//@{
/* Reads VolumeMesh from VTK file.
It looks for lines like these to describe positions of vertices and the four
vertices of each tetrahedron.
POINTS 4 float
0.0 0.0 0.0
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
CELLS 1 5
4 0 1 2 3
CELL_TYPES 1
10
Other sections like POINT_DATA and CELL_DATA, e.g. per-vertex pressure value
or per-tetrahedron velocity field are ignored.
@param filename A file name with absolute path or relative path.
@param scale An optional scale to coordinates.
@return tetrahedral volume mesh
@note Error handling from parsing the file is performed by VTK library.
@throw std::exception if the file does not exist or unsupported.
std::exceptoin for non-positive scale factors.
*/
VolumeMesh<double> ReadVtkToVolumeMesh(const std::string& filename,
double scale = 1.0);
//@}
} // namespace internal
} // namespace geometry
} // namespace drake