Ignition Common

API Reference

4.4.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 
107  public: bool RemoveMesh(const std::string &_name);
108 
110  public: void RemoveAll();
111 
115  public: const ignition::common::Mesh *MeshByName(
116  const std::string &_name) const;
117 
120  public: bool HasMesh(const std::string &_name) const;
121 
127  public: void CreateSphere(const std::string &_name, const float _radius,
128  const int _rings, const int _segments);
129 
134  public: void CreateBox(const std::string &_name,
135  const ignition::math::Vector3d &_sides,
136  const ignition::math::Vector2d &_uvCoords);
137 
150  public: void CreateExtrudedPolyline(const std::string &_name,
152  &_vertices, const double _height);
153 
160  public: void CreateCylinder(const std::string &_name,
161  const float _radius,
162  const float _height,
163  const int _rings,
164  const int _segments);
165 
171  public: void CreateEllipsoid(const std::string &_name,
172  const ignition::math::Vector3d &_radii,
173  const unsigned int _rings,
174  const unsigned int _segments);
175 
182  public: void CreateCapsule(const std::string &_name,
183  const double radius,
184  const double length,
185  const unsigned int _rings,
186  const unsigned int _segments);
187 
194  public: void CreateCone(const std::string &_name,
195  const float _radius,
196  const float _height,
197  const int _rings,
198  const int _segments);
199 
211  public: void CreateTube(const std::string &_name,
212  const float _innerRadius,
213  const float _outterRadius,
214  const float _height,
215  const int _rings,
216  const int _segments,
217  const double _arc = 2.0 * IGN_PI);
218 
224  public: void CreatePlane(const std::string &_name,
225  const ignition::math::Planed &_plane,
226  const ignition::math::Vector2d &_segments,
227  const ignition::math::Vector2d &_uvTile);
228 
236  public: void CreatePlane(const std::string &_name,
237  const ignition::math::Vector3d &_normal,
238  const double _d,
239  const ignition::math::Vector2d &_size,
240  const ignition::math::Vector2d &_segments,
241  const ignition::math::Vector2d &_uvTile);
242 
250  private: void Tesselate2DMesh(SubMesh *_sm,
251  const int _meshWidth,
252  const int _meshHeight,
253  const bool _doubleSided);
254 
258  public: void CreateCamera(const std::string &_name, const float _scale);
259 
266  public: void CreateBoolean(const std::string &_name, const Mesh *_m1,
267  const Mesh *_m2, const int _operation,
269 
277  private: static void ConvertPolylinesToVerticesAndEdges(
279  &_polys,
280  const double _tol,
283 
291  private: static size_t AddUniquePointToVerticesTable(
293  const ignition::math::Vector2d &_p,
294  const double _tol);
295 
297  IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
298 
299 
300  private: friend class SingletonT<MeshManager>;
301  };
302  }
303 }
304 #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