Gazebo Common
API Reference
6.0.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-common
graphics
include
gz
common
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
35
#include <
gz/common/graphics/Types.hh
>
36
#include <
gz/common/SingletonT.hh
>
37
#include <gz/common/graphics/Export.hh>
38
39
namespace
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
110
public
:
void
AddMesh
(
Mesh
*_mesh);
111
116
public
:
bool
RemoveMesh
(
const
std::string
&_name);
117
119
public
:
void
RemoveAll
();
120
124
public
:
const
gz::common::Mesh
*
MeshByName
(
125
const
std::string
&_name)
const
;
126
129
public
:
bool
HasMesh
(
const
std::string
&_name)
const
;
130
136
public
:
void
CreateSphere
(
const
std::string
&_name,
const
float
_radius,
137
const
int
_rings,
const
int
_segments);
138
143
public
:
void
CreateBox
(
const
std::string
&_name,
144
const
gz::math::Vector3d
&_sides,
145
const
gz::math::Vector2d
&_uvCoords);
146
159
public
:
void
CreateExtrudedPolyline
(
const
std::string
&_name,
160
const
std::vector
<
std::vector<gz::math::Vector2d>
>
161
&_vertices,
const
double
_height);
162
169
public
:
void
CreateCylinder
(
const
std::string
&_name,
170
const
float
_radius,
171
const
float
_height,
172
const
int
_rings,
173
const
int
_segments);
174
180
public
:
void
CreateEllipsoid
(
const
std::string
&_name,
181
const
gz::math::Vector3d
&_radii,
182
const
unsigned
int
_rings,
183
const
unsigned
int
_segments);
184
191
public
:
void
CreateCapsule
(
const
std::string
&_name,
192
const
double
radius,
193
const
double
length,
194
const
unsigned
int
_rings,
195
const
unsigned
int
_segments);
196
203
public
:
void
CreateCone
(
const
std::string
&_name,
204
const
float
_radius,
205
const
float
_height,
206
const
int
_rings,
207
const
int
_segments);
208
220
public
:
void
CreateTube
(
const
std::string
&_name,
221
const
float
_innerRadius,
222
const
float
_outterRadius,
223
const
float
_height,
224
const
int
_rings,
225
const
int
_segments,
226
const
double
_arc = 2.0 * GZ_PI);
227
233
public
:
void
CreatePlane
(
const
std::string
&_name,
234
const
gz::math::Planed
&_plane,
235
const
gz::math::Vector2d
&_segments,
236
const
gz::math::Vector2d
&_uvTile);
237
245
public
:
void
CreatePlane
(
const
std::string
&_name,
246
const
gz::math::Vector3d
&_normal,
247
const
double
_d,
248
const
gz::math::Vector2d
&_size,
249
const
gz::math::Vector2d
&_segments,
250
const
gz::math::Vector2d
&_uvTile);
251
255
public
:
void
SetAssimpEnvs
();
256
263
private
:
void
Tesselate2DMesh(
SubMesh
*_sm,
264
const
int
_meshWidth,
265
const
int
_meshHeight,
266
const
bool
_doubleSided);
267
271
public
:
void
CreateCamera
(
const
std::string
&_name,
const
float
_scale);
272
283
public
:
static
std::vector<SubMesh>
ConvexDecomposition
(
284
const
common::SubMesh
&_subMesh,
285
std::size_t
_maxConvexHulls = 16u,
286
std::size_t
_voxelResolution = 200000u);
287
291
public
:
static
std::unique_ptr<Mesh>
MergeSubMeshes
(
292
const
common::Mesh
&_mesh);
293
301
private
:
static
void
ConvertPolylinesToVerticesAndEdges(
302
const
std::vector
<
std::vector<gz::math::Vector2d>
>
303
&_polys,
304
const
double
_tol,
305
std::vector<gz::math::Vector2d>
&_vertices,
306
std::vector<gz::math::Vector2i>
&_edges);
307
315
private
:
static
size_t
AddUniquePointToVerticesTable(
316
std::vector<gz::math::Vector2d>
&_vertices,
317
const
gz::math::Vector2d
&_p,
318
const
double
_tol);
319
321
GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
322
323
324
private
:
friend
class
SingletonT
<
MeshManager
>;
325
};
326
}
327
}
328
#endif