@@ -35,6 +35,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
35
35
#include < tesseract_geometry/geometry.h>
36
36
#include < tesseract_common/types.h>
37
37
#include < tesseract_common/resource.h>
38
+ #include < tesseract_geometry/impl/mesh_material.h>
38
39
39
40
#ifdef SWIG
40
41
%shared_ptr(tesseract_geometry::ConvexMesh)
@@ -43,10 +44,6 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
43
44
44
45
namespace tesseract_geometry
45
46
{
46
- #ifdef SWIG
47
- %nodefaultctor ConvexMesh;
48
- #endif // SWIG
49
-
50
47
class ConvexMesh : public Geometry
51
48
{
52
49
public:
@@ -55,7 +52,6 @@ class ConvexMesh : public Geometry
55
52
using Ptr = std::shared_ptr<ConvexMesh>;
56
53
using ConstPtr = std::shared_ptr<const ConvexMesh>;
57
54
58
- #ifndef SWIG
59
55
/* *
60
56
* @brief Convex Mesh geometry
61
57
* @param vertices A vector of vertices associated with the mesh
@@ -65,16 +61,28 @@ class ConvexMesh : public Geometry
65
61
* three vertices that define this face followed by three indices.
66
62
* @param resource A resource locator for locating resource
67
63
* @param scale Scale the mesh
64
+ * @param normals A vector of normals for the vertices (optional)
65
+ * @param vertex_colors A vector of colors (RGBA) for the vertices (optional)
66
+ * @param mesh_material A MeshMaterial describing the color and material properties of the mesh (optional)
67
+ * @param mesh_textures A vector of MeshTexture to apply to the mesh (optional)
68
68
*/
69
69
ConvexMesh (std::shared_ptr<const tesseract_common::VectorVector3d> vertices,
70
70
std::shared_ptr<const Eigen::VectorXi> faces,
71
71
tesseract_common::Resource::Ptr resource = nullptr ,
72
- Eigen::Vector3d scale = Eigen::Vector3d(1 , 1 , 1 ))
72
+ Eigen::Vector3d scale = Eigen::Vector3d(1 , 1 , 1 ),
73
+ std::shared_ptr<const tesseract_common::VectorVector3d> normals = nullptr ,
74
+ std::shared_ptr<const tesseract_common::VectorVector4d> vertex_colors = nullptr ,
75
+ MeshMaterial::Ptr mesh_material = nullptr ,
76
+ std::shared_ptr<const std::vector<MeshTexture::Ptr>> mesh_textures = nullptr )
73
77
: Geometry(GeometryType::CONVEX_MESH)
74
78
, vertices_(std::move(vertices))
75
79
, faces_(std::move(faces))
76
80
, resource_(std::move(resource))
77
81
, scale_(std::move(scale))
82
+ , normals_(std::move(normals))
83
+ , vertex_colors_(std::move(vertex_colors))
84
+ , mesh_material_(std::move(mesh_material))
85
+ , mesh_textures_(std::move(mesh_textures))
78
86
{
79
87
vertice_count_ = static_cast <int >(vertices_->size ());
80
88
@@ -97,46 +105,40 @@ class ConvexMesh : public Geometry
97
105
* @param face_count Provide the number of faces. This is faster because it does not need to loop over triangles.
98
106
* @param resource A resource locator for locating resource
99
107
* @param scale Scale the mesh
108
+ * @param normals A vector of normals for the vertices (optional)
109
+ * @param vertex_colors A vector of colors (RGBA) for the vertices (optional)
110
+ * @param mesh_material A MeshMaterial describing the color and material properties of the mesh (optional)
111
+ * @param mesh_textures A vector of MeshTexture to apply to the mesh (optional)
100
112
*/
101
113
ConvexMesh (std::shared_ptr<const tesseract_common::VectorVector3d> vertices,
102
114
std::shared_ptr<const Eigen::VectorXi> faces,
103
115
int face_count,
104
116
tesseract_common::Resource::Ptr resource = nullptr ,
105
- Eigen::Vector3d scale = Eigen::Vector3d(1 , 1 , 1 ))
117
+ Eigen::Vector3d scale = Eigen::Vector3d(1 , 1 , 1 ),
118
+ std::shared_ptr<const tesseract_common::VectorVector3d> normals = nullptr ,
119
+ std::shared_ptr<const tesseract_common::VectorVector4d> vertex_colors = nullptr ,
120
+ MeshMaterial::Ptr mesh_material = nullptr ,
121
+ std::shared_ptr<const std::vector<MeshTexture::Ptr>> mesh_textures = nullptr )
106
122
: Geometry(GeometryType::CONVEX_MESH)
107
123
, vertices_(std::move(vertices))
108
124
, faces_(std::move(faces))
109
125
, face_count_(face_count)
110
126
, resource_(std::move(resource))
111
127
, scale_(std::move(scale))
128
+ , normals_(std::move(normals))
129
+ , vertex_colors_(std::move(vertex_colors))
130
+ , mesh_material_(std::move(mesh_material))
131
+ , mesh_textures_(std::move(mesh_textures))
112
132
{
113
133
vertice_count_ = static_cast <int >(vertices_->size ());
114
134
}
115
135
116
- #endif // SWIG
117
-
118
- #ifdef SWIG
119
- %extend
120
- {
121
- ConvexMesh (const tesseract_common::VectorVector3d& vertices,
122
- const Eigen::VectorXi& triangles,
123
- tesseract_common::Resource::Ptr resource = nullptr ,
124
- Eigen::Vector3d scale = Eigen::Vector3d (1 , 1 , 1 ))
125
- {
126
- return new tesseract_geometry::ConvexMesh (std::make_shared<tesseract_common::VectorVector3d>(vertices),
127
- std::make_shared<Eigen::VectorXi>(triangles),
128
- resource, scale);
129
- }
130
- }
131
- #endif // SWIG
132
-
133
136
~ConvexMesh () override = default ;
134
137
ConvexMesh (const ConvexMesh&) = delete ;
135
138
ConvexMesh& operator =(const ConvexMesh&) = delete ;
136
139
ConvexMesh (ConvexMesh&&) = delete ;
137
140
ConvexMesh& operator =(ConvexMesh&&) = delete ;
138
141
139
- #ifndef SWIG
140
142
/* *
141
143
* @brief Get convex mesh vertices
142
144
* @return A vector of vertices
@@ -149,17 +151,6 @@ class ConvexMesh : public Geometry
149
151
*/
150
152
const std::shared_ptr<const Eigen::VectorXi>& getFaces () const { return faces_; }
151
153
152
- #else // SWIG
153
- // clang-format off
154
- %extend
155
- {
156
- tesseract_common::VectorVector3d getVertices () { return *$self->getVertices (); }
157
-
158
- Eigen::VectorXi getFaces () { return *$self->getFaces (); }
159
- }
160
- // clang-format on
161
- #endif // SWIG
162
-
163
154
/* *
164
155
* @brief Get vertice count
165
156
* @return Number of vertices
@@ -187,6 +178,46 @@ class ConvexMesh : public Geometry
187
178
*/
188
179
const Eigen::Vector3d& getScale () const { return scale_; }
189
180
181
+ /* *
182
+ * @brief Get the vertice normal vectors
183
+ *
184
+ * Optional, may be nullptr
185
+ *
186
+ * @return The vertice normal vector
187
+ */
188
+ std::shared_ptr<const tesseract_common::VectorVector3d> getNormals () const { return normals_; }
189
+
190
+ /* *
191
+ * @brief Get the vertex colors
192
+ *
193
+ * Optional, may be nullptr
194
+ *
195
+ * @return Vertex colors
196
+ */
197
+ std::shared_ptr<const tesseract_common::VectorVector4d> getVertexColors () const { return vertex_colors_; }
198
+
199
+ /* *
200
+ * @brief Get material data extracted from the mesh file
201
+ *
202
+ * Mesh files contain material information. The mesh parser will
203
+ * extract the material information and store it in a MeshMaterial structure.
204
+ *
205
+ * @return The MeshMaterial data extracted from mesh file
206
+ */
207
+ MeshMaterial::ConstPtr getMaterial () const { return mesh_material_; }
208
+
209
+ /* *
210
+ * @brief Get textures extracted from the mesh file
211
+ *
212
+ * Mesh files contain (or reference) image files that form textures on the surface
213
+ * of the mesh. UV coordinates specify how the image is applied to the mesh. The
214
+ * MeshTexture structure contains a resource to the image, and the UV coordinates.
215
+ * Currently only jpg and png image formats are supported.
216
+ *
217
+ * @return Vector of mesh textures
218
+ */
219
+ std::shared_ptr<const std::vector<MeshTexture::Ptr>> getTextures () const { return mesh_textures_; }
220
+
190
221
Geometry::Ptr clone () const override
191
222
{
192
223
return std::make_shared<ConvexMesh>(vertices_, faces_, face_count_, resource_, scale_);
@@ -200,6 +231,10 @@ class ConvexMesh : public Geometry
200
231
int face_count_;
201
232
tesseract_common::Resource::Ptr resource_;
202
233
Eigen::Vector3d scale_;
234
+ std::shared_ptr<const tesseract_common::VectorVector3d> normals_;
235
+ std::shared_ptr<const tesseract_common::VectorVector4d> vertex_colors_;
236
+ MeshMaterial::Ptr mesh_material_;
237
+ std::shared_ptr<const std::vector<MeshTexture::Ptr>> mesh_textures_;
203
238
};
204
239
} // namespace tesseract_geometry
205
240
#endif
0 commit comments