Gazebo Common

API Reference

4.7.0
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 IGNITION_COMMON_MESHMANAGER_HH_
18 #define IGNITION_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 <ignition/utils/ImplPtr.hh>
34 
35 #include <gz/common/config.hh>
37 #include <gz/common/SingletonT.hh>
38 #include <gz/common/graphics/Export.hh>
39 
40 namespace ignition
41 {
42  namespace common
43  {
45  class Mesh;
46  class SubMesh;
47 
50  class IGNITION_COMMON_GRAPHICS_VISIBLE MeshManager
51  : public SingletonT<MeshManager>
52  {
54  private: MeshManager();
55 
59  private: virtual ~MeshManager();
60 
64  public: static MeshManager* Instance();
65 
71  public: const Mesh *Load(const std::string &_filename);
72 
79  public: void Export(const Mesh *_mesh, const std::string &_filename,
80  const std::string &_extension, bool _exportTextures = false);
81 
84  public: bool IsValidFilename(const std::string &_filename);
85 
91  public: void MeshAABB(const Mesh *_mesh,
92  ignition::math::Vector3d &_center,
93  ignition::math::Vector3d &_min_xyz,
94  ignition::math::Vector3d &_max_xyz);
95 
99  public: void GenSphericalTexCoord(const Mesh *_mesh,
100  const ignition::math::Vector3d &_center);
101 
107  public: void AddMesh(Mesh *_mesh);
108 
113  public: bool RemoveMesh(const std::string &_name);
114 
116  public: void RemoveAll();
117 
121  public: const ignition::common::Mesh *MeshByName(
122  const std::string &_name) const;
123 
126  public: bool HasMesh(const std::string &_name) const;
127 
133  public: void CreateSphere(const std::string &_name, const float _radius,
134  const int _rings, const int _segments);
135 
140  public: void CreateBox(const std::string &_name,
141  const ignition::math::Vector3d &_sides,
142  const ignition::math::Vector2d &_uvCoords);
143 
156  public: void CreateExtrudedPolyline(const std::string &_name,
158  &_vertices, const double _height);
159 
166  public: void CreateCylinder(const std::string &_name,
167  const float _radius,
168  const float _height,
169  const int _rings,
170  const int _segments);
171 
177  public: void CreateEllipsoid(const std::string &_name,
178  const ignition::math::Vector3d &_radii,
179  const unsigned int _rings,
180  const unsigned int _segments);
181 
188  public: void CreateCapsule(const std::string &_name,
189  const double radius,
190  const double length,
191  const unsigned int _rings,
192  const unsigned int _segments);
193 
200  public: void CreateCone(const std::string &_name,
201  const float _radius,
202  const float _height,
203  const int _rings,
204  const int _segments);
205 
217  public: void CreateTube(const std::string &_name,
218  const float _innerRadius,
219  const float _outterRadius,
220  const float _height,
221  const int _rings,
222  const int _segments,
223  const double _arc = 2.0 * IGN_PI);
224 
230  public: void CreatePlane(const std::string &_name,
231  const ignition::math::Planed &_plane,
232  const ignition::math::Vector2d &_segments,
233  const ignition::math::Vector2d &_uvTile);
234 
242  public: void CreatePlane(const std::string &_name,
243  const ignition::math::Vector3d &_normal,
244  const double _d,
245  const ignition::math::Vector2d &_size,
246  const ignition::math::Vector2d &_segments,
247  const ignition::math::Vector2d &_uvTile);
248 
256  private: void Tesselate2DMesh(SubMesh *_sm,
257  const int _meshWidth,
258  const int _meshHeight,
259  const bool _doubleSided);
260 
264  public: void CreateCamera(const std::string &_name, const float _scale);
265 
272  public: void CreateBoolean(const std::string &_name, const Mesh *_m1,
273  const Mesh *_m2, const int _operation,
275 
283  private: static void ConvertPolylinesToVerticesAndEdges(
285  &_polys,
286  const double _tol,
289 
297  private: static size_t AddUniquePointToVerticesTable(
299  const ignition::math::Vector2d &_p,
300  const double _tol);
301 
303  IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
304 
305 
306  private: friend class SingletonT<MeshManager>;
307  };
308  }
309 }
310 #endif
Forward declarations for the common classes.
STL class.
#define IGN_PI
STL class.
Singleton template class.
Definition: gz/common/SingletonT.hh:29
static const Pose3< T > Zero
A 3D mesh.
Definition: gz/common/Mesh.hh:42
Maintains and manages all meshes.
Definition: gz/common/MeshManager.hh:50
A child mesh.
Definition: gz/common/SubMesh.hh:42