Ignition Common

API Reference

4.1.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 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 <ignition/math/Plane.hh>
27 #include <ignition/math/Matrix3.hh>
28 #include <ignition/math/Matrix4.hh>
29 #include <ignition/math/Vector2.hh>
30 #include <ignition/math/Vector3.hh>
31 #include <ignition/math/Pose3.hh>
32 
33 #include <ignition/utils/ImplPtr.hh>
34 
37 #include <ignition/common/graphics/Export.hh>
38 
39 namespace ignition
40 {
41  namespace common
42  {
44  class Mesh;
45  class SubMesh;
46 
49  class IGNITION_COMMON_GRAPHICS_VISIBLE MeshManager
50  : public SingletonT<MeshManager>
51  {
53  private: MeshManager();
54 
58  private: virtual ~MeshManager();
59 
65  public: const Mesh *Load(const std::string &_filename);
66 
73  public: void Export(const Mesh *_mesh, const std::string &_filename,
74  const std::string &_extension, bool _exportTextures = false);
75 
78  public: bool IsValidFilename(const std::string &_filename);
79 
85  public: void MeshAABB(const Mesh *_mesh,
86  ignition::math::Vector3d &_center,
87  ignition::math::Vector3d &_min_xyz,
88  ignition::math::Vector3d &_max_xyz);
89 
93  public: void GenSphericalTexCoord(const Mesh *_mesh,
94  const ignition::math::Vector3d &_center);
95 
101  public: void AddMesh(Mesh *_mesh);
102 
106  public: const ignition::common::Mesh *MeshByName(
107  const std::string &_name) const;
108 
111  public: bool HasMesh(const std::string &_name) const;
112 
118  public: void CreateSphere(const std::string &_name, const float _radius,
119  const int _rings, const int _segments);
120 
125  public: void CreateBox(const std::string &_name,
126  const ignition::math::Vector3d &_sides,
127  const ignition::math::Vector2d &_uvCoords);
128 
141  public: void CreateExtrudedPolyline(const std::string &_name,
143  &_vertices, const double _height);
144 
151  public: void CreateCylinder(const std::string &_name,
152  const float _radius,
153  const float _height,
154  const int _rings,
155  const int _segments);
156 
162  public: void CreateEllipsoid(const std::string &_name,
163  const ignition::math::Vector3d &_radii,
164  const unsigned int _rings,
165  const unsigned int _segments);
166 
173  public: void CreateCapsule(const std::string &_name,
174  const double radius,
175  const double length,
176  const unsigned int _rings,
177  const unsigned int _segments);
178 
185  public: void CreateCone(const std::string &_name,
186  const float _radius,
187  const float _height,
188  const int _rings,
189  const int _segments);
190 
202  public: void CreateTube(const std::string &_name,
203  const float _innerRadius,
204  const float _outterRadius,
205  const float _height,
206  const int _rings,
207  const int _segments,
208  const double _arc = 2.0 * IGN_PI);
209 
215  public: void CreatePlane(const std::string &_name,
216  const ignition::math::Planed &_plane,
217  const ignition::math::Vector2d &_segments,
218  const ignition::math::Vector2d &_uvTile);
219 
227  public: void CreatePlane(const std::string &_name,
228  const ignition::math::Vector3d &_normal,
229  const double _d,
230  const ignition::math::Vector2d &_size,
231  const ignition::math::Vector2d &_segments,
232  const ignition::math::Vector2d &_uvTile);
233 
241  private: void Tesselate2DMesh(SubMesh *_sm,
242  const int _meshWidth,
243  const int _meshHeight,
244  const bool _doubleSided);
245 
249  public: void CreateCamera(const std::string &_name, const float _scale);
250 
257  public: void CreateBoolean(const std::string &_name, const Mesh *_m1,
258  const Mesh *_m2, const int _operation,
260 
268  private: static void ConvertPolylinesToVerticesAndEdges(
270  &_polys,
271  const double _tol,
274 
282  private: static size_t AddUniquePointToVerticesTable(
284  const ignition::math::Vector2d &_p,
285  const double _tol);
286 
288  IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
289 
290 
291  private: friend class SingletonT<MeshManager>;
292  };
293  }
294 }
295 #endif
static const Pose3< T > Zero
STL class.
A child mesh.
Definition: SubMesh.hh:41
Singleton template class.
Definition: SingletonT.hh:27
STL class.
Forward declarations for the common classes.
Maintains and manages all meshes.
Definition: MeshManager.hh:49
#define IGN_PI
A 3D mesh.
Definition: Mesh.hh:41