Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
sdf_mesh.h
Go to the documentation of this file.
1
26#ifndef TESSERACT_GEOMETRY_SDF_MESH_H
27#define TESSERACT_GEOMETRY_SDF_MESH_H
28
31#include <boost/serialization/access.hpp>
32#include <boost/serialization/export.hpp>
33#include <Eigen/Geometry>
34#include <memory>
36
40
41namespace tesseract_geometry
42{
43class SDFMesh : public PolygonMesh
44{
45public:
46 // LCOV_EXCL_START
47 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
48 // LCOV_EXCL_STOP
49
50 using Ptr = std::shared_ptr<SDFMesh>;
51 using ConstPtr = std::shared_ptr<const SDFMesh>;
52
67 SDFMesh(std::shared_ptr<const tesseract_common::VectorVector3d> vertices,
68 std::shared_ptr<const Eigen::VectorXi> triangles,
70 const Eigen::Vector3d& scale = Eigen::Vector3d(1, 1, 1),
71 std::shared_ptr<const tesseract_common::VectorVector3d> normals = nullptr,
72 std::shared_ptr<const tesseract_common::VectorVector4d> vertex_colors = nullptr,
73 MeshMaterial::Ptr mesh_material = nullptr,
74 std::shared_ptr<const std::vector<MeshTexture::Ptr>> mesh_textures = nullptr)
75 : PolygonMesh(std::move(vertices),
76 std::move(triangles),
77 std::move(resource),
78 scale,
79 std::move(normals),
80 std::move(vertex_colors),
81 std::move(mesh_material),
82 std::move(mesh_textures),
84 {
85 if ((static_cast<long>(getFaceCount()) * 4) != getFaces()->size())
86 std::throw_with_nested(std::runtime_error("Mesh is not triangular")); // LCOV_EXCL_LINE
87 }
88
104 SDFMesh(std::shared_ptr<const tesseract_common::VectorVector3d> vertices,
105 std::shared_ptr<const Eigen::VectorXi> triangles,
106 int triangle_count,
108 const Eigen::Vector3d& scale = Eigen::Vector3d(1, 1, 1),
109 std::shared_ptr<const tesseract_common::VectorVector3d> normals = nullptr,
110 std::shared_ptr<const tesseract_common::VectorVector4d> vertex_colors = nullptr,
111 MeshMaterial::Ptr mesh_material = nullptr,
112 std::shared_ptr<const std::vector<MeshTexture::Ptr>> mesh_textures = nullptr)
113 : PolygonMesh(std::move(vertices),
114 std::move(triangles),
115 triangle_count,
116 std::move(resource),
117 scale,
118 std::move(normals),
119 std::move(vertex_colors),
120 std::move(mesh_material),
121 std::move(mesh_textures),
123 {
124 if ((static_cast<long>(getFaceCount()) * 4) != getFaces()->size())
125 std::throw_with_nested(std::runtime_error("Mesh is not triangular")); // LCOV_EXCL_LINE
126 }
127
128 SDFMesh() = default;
129 ~SDFMesh() override = default;
130
131 Geometry::Ptr clone() const override
132 {
133 return std::make_shared<SDFMesh>(getVertices(), getFaces(), getFaceCount(), getResource(), getScale());
134 }
135
136 bool operator==(const SDFMesh& rhs) const;
137 bool operator!=(const SDFMesh& rhs) const;
138
139private:
141 template <class Archive>
142 void serialize(Archive& ar, const unsigned int version); // NOLINT
143};
144} // namespace tesseract_geometry
145
146BOOST_CLASS_EXPORT_KEY2(tesseract_geometry::SDFMesh, "SDFMesh")
147#endif
std::shared_ptr< const Resource > ConstPtr
Definition: resource_locator.h:102
std::shared_ptr< Resource > Ptr
Definition: resource_locator.h:101
std::shared_ptr< Geometry > Ptr
Definition: geometry.h:62
std::shared_ptr< MeshMaterial > Ptr
Definition: mesh_material.h:63
Definition: polygon_mesh.h:46
const std::shared_ptr< const Eigen::VectorXi > & getFaces() const
Get Polygon mesh faces.
Definition: polygon_mesh.h:152
int getFaceCount() const
Get face count.
Definition: polygon_mesh.h:164
tesseract_common::Resource::ConstPtr getResource() const
Get the path to file used to generate the mesh.
Definition: polygon_mesh.h:173
const std::shared_ptr< const tesseract_common::VectorVector3d > & getVertices() const
Get Polygon mesh vertices.
Definition: polygon_mesh.h:146
const Eigen::Vector3d & getScale() const
Get the scale applied to file used to generate the mesh.
Definition: polygon_mesh.h:179
Definition: sdf_mesh.h:44
std::shared_ptr< SDFMesh > Ptr
Definition: sdf_mesh.h:50
bool operator==(const SDFMesh &rhs) const
Definition: sdf_mesh.cpp:38
bool operator!=(const SDFMesh &rhs) const
Definition: sdf_mesh.cpp:44
Geometry::Ptr clone() const override
Create a copy of this shape.
Definition: sdf_mesh.h:131
std::shared_ptr< const SDFMesh > ConstPtr
Definition: sdf_mesh.h:51
SDFMesh(std::shared_ptr< const tesseract_common::VectorVector3d > vertices, std::shared_ptr< const Eigen::VectorXi > triangles, tesseract_common::Resource::Ptr resource=nullptr, const Eigen::Vector3d &scale=Eigen::Vector3d(1, 1, 1), std::shared_ptr< const tesseract_common::VectorVector3d > normals=nullptr, std::shared_ptr< const tesseract_common::VectorVector4d > vertex_colors=nullptr, MeshMaterial::Ptr mesh_material=nullptr, std::shared_ptr< const std::vector< MeshTexture::Ptr > > mesh_textures=nullptr)
SDF Mesh geometry.
Definition: sdf_mesh.h:67
SDFMesh(std::shared_ptr< const tesseract_common::VectorVector3d > vertices, std::shared_ptr< const Eigen::VectorXi > triangles, int triangle_count, tesseract_common::Resource::ConstPtr resource=nullptr, const Eigen::Vector3d &scale=Eigen::Vector3d(1, 1, 1), std::shared_ptr< const tesseract_common::VectorVector3d > normals=nullptr, std::shared_ptr< const tesseract_common::VectorVector4d > vertex_colors=nullptr, MeshMaterial::Ptr mesh_material=nullptr, std::shared_ptr< const std::vector< MeshTexture::Ptr > > mesh_textures=nullptr)
SDF Mesh geometry.
Definition: sdf_mesh.h:104
friend class boost::serialization::access
Definition: sdf_mesh.h:140
~SDFMesh() override=default
void serialize(Archive &ar, const unsigned int version)
Definition: sdf_mesh.cpp:47
double scale
Definition: collision_margin_data_unit.cpp:133
Common Tesseract Macros.
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Tesseract Mesh Material read from a mesh file.
Definition: create_convex_hull.cpp:36
Definition: geometry.h:39
GeometryType
Definition: geometry.h:41
@ SDF_MESH
Definition: geometry.h:51
Tesseract Polygon Mesh Geometry.
Resource::Ptr resource
Definition: resource_locator_unit.cpp:59
Tesseract Geometries.