Gazebo Common

API Reference

7.3.0
MeshManager.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17#ifndef GZ_COMMON_MESHMANAGER_HH_
18#define GZ_COMMON_MESHMANAGER_HH_
19
20#include <map>
21#include <utility>
22#include <string>
23#include <vector>
24#include <memory>
25
26#include <gz/math/Plane.hh>
27#include <gz/math/Matrix3.hh>
28#include <gz/math/Matrix4.hh>
29#include <gz/math/Vector2.hh>
30#include <gz/math/Vector3.hh>
31#include <gz/math/Pose3.hh>
32
33#include <gz/utils/ImplPtr.hh>
34
37#include <gz/common/graphics/Export.hh>
38
39namespace gz
40{
41 namespace common
42 {
44 class Mesh;
45 class SubMesh;
46
53 class GZ_COMMON_GRAPHICS_VISIBLE MeshManager
54 : public SingletonT<MeshManager>
55 {
57 private: MeshManager();
58
62 private: virtual ~MeshManager();
63
67 public: static MeshManager* Instance();
68
74 public: const Mesh *Load(const std::string &_filename);
75
82 public: void Export(const Mesh *_mesh, const std::string &_filename,
83 const std::string &_extension, bool _exportTextures = false);
84
87 public: bool IsValidFilename(const std::string &_filename);
88
94 public: void MeshAABB(const Mesh *_mesh,
95 gz::math::Vector3d &_center,
96 gz::math::Vector3d &_min_xyz,
97 gz::math::Vector3d &_max_xyz);
98
102 public: void GenSphericalTexCoord(const Mesh *_mesh,
103 const gz::math::Vector3d &_center);
104
114 public: void AddMesh(Mesh *_mesh);
115
120 public: bool RemoveMesh(const std::string &_name);
121
123 public: void RemoveAll();
124
129 const std::string &_name) const;
130
133 public: bool HasMesh(const std::string &_name) const;
134
140 public: common::Mesh *CreateMesh(const std::string &_name);
141
147 public: void CreateSphere(const std::string &_name, const float _radius,
148 const int _rings, const int _segments);
149
154 public: void CreateBox(const std::string &_name,
155 const gz::math::Vector3d &_sides,
156 const gz::math::Vector2d &_uvCoords);
157
170 public: void CreateExtrudedPolyline(const std::string &_name,
172 &_vertices, const double _height);
173
180 public: void CreateCylinder(const std::string &_name,
181 const float _radius,
182 const float _height,
183 const int _rings,
184 const int _segments);
185
191 public: void CreateEllipsoid(const std::string &_name,
192 const gz::math::Vector3d &_radii,
193 const unsigned int _rings,
194 const unsigned int _segments);
195
202 public: void CreateCapsule(const std::string &_name,
203 const double radius,
204 const double length,
205 const unsigned int _rings,
206 const unsigned int _segments);
207
214 public: void CreateCone(const std::string &_name,
215 const float _radius,
216 const float _height,
217 const int _rings,
218 const int _segments);
219
231 public: void CreateTube(const std::string &_name,
232 const float _innerRadius,
233 const float _outterRadius,
234 const float _height,
235 const int _rings,
236 const int _segments,
237 const double _arc = 2.0 * GZ_PI);
238
244 public: void CreatePlane(const std::string &_name,
245 const gz::math::Planed &_plane,
246 const gz::math::Vector2d &_segments,
247 const gz::math::Vector2d &_uvTile);
248
256 public: void CreatePlane(const std::string &_name,
257 const gz::math::Vector3d &_normal,
258 const double _d,
259 const gz::math::Vector2d &_size,
260 const gz::math::Vector2d &_segments,
261 const gz::math::Vector2d &_uvTile);
262
266 public: void SetAssimpEnvs();
267
274 private: void Tesselate2DMesh(SubMesh *_sm,
275 const int _meshWidth,
276 const int _meshHeight,
277 const bool _doubleSided);
278
282 public: void CreateCamera(const std::string &_name, const float _scale);
283
295 const common::SubMesh &_subMesh,
296 std::size_t _maxConvexHulls = 16u,
297 std::size_t _voxelResolution = 200000u);
298
303 const common::Mesh &_mesh);
304
312 private: static void ConvertPolylinesToVerticesAndEdges(
314 &_polys,
315 const double _tol,
318
326 private: static size_t AddUniquePointToVerticesTable(
328 const gz::math::Vector2d &_p,
329 const double _tol);
330
332 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
333
334
335 private: friend class SingletonT<MeshManager>;
336 };
337 }
338}
339#endif