-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
mesh_deformer.cc
33 lines (27 loc) · 1.06 KB
/
mesh_deformer.cc
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
#include "drake/geometry/proximity/mesh_deformer.h"
#include <fmt/format.h>
#include "drake/geometry/proximity/triangle_surface_mesh.h"
#include "drake/geometry/proximity/volume_mesh.h"
namespace drake {
namespace geometry {
namespace internal {
template <typename MeshType>
void MeshDeformer<MeshType>::SetAllPositions(
const Eigen::Ref<const VectorX<T>>& p_MVs) {
if (p_MVs.size() != 3 * mesh_.num_vertices()) {
throw std::runtime_error(fmt::format(
"MeshDeformer::SetAllPositions(): Attempting to deform a mesh with {} "
"vertices with data for {} vertices",
mesh_.num_vertices(), p_MVs.size()));
}
for (int v = 0, i = 0; v < mesh_.num_vertices(); ++v, i += 3) {
mesh_.vertices_[v] = Vector3<T>(p_MVs[i], p_MVs[i + 1], p_MVs[i + 2]);
}
}
template class MeshDeformer<VolumeMesh<double>>;
template class MeshDeformer<VolumeMesh<AutoDiffXd>>;
template class MeshDeformer<TriangleSurfaceMesh<double>>;
template class MeshDeformer<TriangleSurfaceMesh<AutoDiffXd>>;
} // namespace internal
} // namespace geometry
} // namespace drake