Gazebo Common

API Reference

3.17.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 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 
34 #include <gz/common/SingletonT.hh>
35 #include <gz/common/graphics/Export.hh>
37 
38 namespace ignition
39 {
40  namespace common
41  {
43  class Mesh;
44  class SubMesh;
45  class MeshManagerPrivate;
46 
49  class IGNITION_COMMON_GRAPHICS_VISIBLE MeshManager
50  : public SingletonT<MeshManager>
51  {
53  private: MeshManager();
54 
58  private: virtual ~MeshManager();
59 
63  public: static MeshManager* Instance();
64 
70  public: const Mesh *Load(const std::string &_filename);
71 
78  public: void Export(const Mesh *_mesh, const std::string &_filename,
79  const std::string &_extension, bool _exportTextures = false);
80 
83  public: bool IsValidFilename(const std::string &_filename);
84 
90  public: void MeshAABB(const Mesh *_mesh,
91  gz::math::Vector3d &_center,
92  gz::math::Vector3d &_min_xyz,
93  gz::math::Vector3d &_max_xyz);
94 
98  public: void GenSphericalTexCoord(const Mesh *_mesh,
99  const gz::math::Vector3d &_center);
100 
106  public: void AddMesh(Mesh *_mesh);
107 
111  public: const gz::common::Mesh *MeshByName(
112  const std::string &_name) const;
113 
116  public: bool HasMesh(const std::string &_name) const;
117 
123  public: void CreateSphere(const std::string &_name, const float _radius,
124  const int _rings, const int _segments);
125 
130  public: void CreateBox(const std::string &_name,
131  const gz::math::Vector3d &_sides,
132  const gz::math::Vector2d &_uvCoords);
133 
146  public: void CreateExtrudedPolyline(const std::string &_name,
148  &_vertices, const double _height);
149 
156  public: void CreateCylinder(const std::string &_name,
157  const float _radius,
158  const float _height,
159  const int _rings,
160  const int _segments);
161 
167  public: void CreateEllipsoid(const std::string &_name,
168  const gz::math::Vector3d &_radii,
169  const unsigned int _rings,
170  const unsigned int _segments);
171 
178  public: void CreateCapsule(const std::string &_name,
179  const double radius,
180  const double length,
181  const unsigned int _rings,
182  const unsigned int _segments);
183 
190  public: void CreateCone(const std::string &_name,
191  const float _radius,
192  const float _height,
193  const int _rings,
194  const int _segments);
195 
207  public: void CreateTube(const std::string &_name,
208  const float _innerRadius,
209  const float _outterRadius,
210  const float _height,
211  const int _rings,
212  const int _segments,
213  const double _arc = 2.0 * IGN_PI);
214 
220  public: void CreatePlane(const std::string &_name,
221  const gz::math::Planed &_plane,
222  const gz::math::Vector2d &_segments,
223  const gz::math::Vector2d &_uvTile);
224 
232  public: void CreatePlane(const std::string &_name,
233  const gz::math::Vector3d &_normal,
234  const double _d,
235  const gz::math::Vector2d &_size,
236  const gz::math::Vector2d &_segments,
237  const gz::math::Vector2d &_uvTile);
238 
246  private: void Tesselate2DMesh(SubMesh *_sm,
247  const int _meshWidth,
248  const int _meshHeight,
249  const bool _doubleSided);
250 
254  public: void CreateCamera(const std::string &_name, const float _scale);
255 
262  public: void CreateBoolean(const std::string &_name, const Mesh *_m1,
263  const Mesh *_m2, const int _operation,
264  const gz::math::Pose3d &_offset = gz::math::Pose3d::Zero);
265 
273  private: static void ConvertPolylinesToVerticesAndEdges(
275  &_polys,
276  const double _tol,
279 
287  private: static size_t AddUniquePointToVerticesTable(
289  const gz::math::Vector2d &_p,
290  const double _tol);
291 
294  private: std::unique_ptr<MeshManagerPrivate> dataPtr;
296 
298  private: friend class SingletonT<MeshManager>;
299  };
300  }
301 }
302 #endif
Forward declarations for the common classes.
STL class.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: gz/common/SuppressWarning.hh:65
#define IGN_PI
STL class.
Singleton template class.
Definition: gz/common/SingletonT.hh:27
A 3D mesh.
Definition: gz/common/Mesh.hh:41
Maintains and manages all meshes.
Definition: gz/common/MeshManager.hh:49
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: gz/common/SuppressWarning.hh:68
A child mesh.
Definition: gz/common/SubMesh.hh:40