-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
internal_vtk_util.h
53 lines (45 loc) · 1.69 KB
/
internal_vtk_util.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
#pragma once
#include <array>
#include <Eigen/Dense>
#include <vtkNew.h>
#include <vtkPlaneSource.h>
#include <vtkSmartPointer.h>
#include <vtkTransform.h>
#include "drake/common/drake_copyable.h"
#include "drake/math/rigid_transform.h"
namespace drake {
namespace geometry {
namespace render_vtk {
namespace internal {
/// An array type for vtkSmartPointer.
///
/// @tparam T The VTK class type stored in vtkSmartPointer.
/// @tparam N The size of array.
template <typename T, size_t N>
using vtkPointerArray = std::array<vtkSmartPointer<T>, N>;
/// Creates a square plane of the given size. The plane's z axis is its
/// normal and is coincident with the z axis of the world coordinate system.
/// The plane's center is at (0, 0, 0) of both the world coordinate system and
/// plane's coordinate system. The ranges of the plane's x and y are
/// `(- size / 2, size / 2)`.
///
/// @param size The size of the plane.
vtkSmartPointer<vtkPlaneSource> CreateSquarePlane(double size);
/// Converts the provided `transform` to a vtkTransform.
vtkSmartPointer<vtkTransform> ConvertToVtkTransform(
const math::RigidTransformd& transform);
/// Makes vtkPointerArray from one or multiple pointer(s) for VTK objects
/// wrapped by vtkNew.
///
/// @tparam transform The transform to convert into a `vtkTransform`.
template <typename T, typename... Ts, size_t N = 1 + sizeof...(Ts)>
const vtkPointerArray<T, N> MakeVtkPointerArray(
const vtkNew<T>& element, const vtkNew<Ts>&... elements) {
return vtkPointerArray<T, N>{{
vtkSmartPointer<T>(element.GetPointer()),
vtkSmartPointer<Ts>(elements.GetPointer())...}};
}
} // namespace internal
} // namespace render_vtk
} // namespace geometry
} // namespace drake