Ignition Common

API Reference

3.6.1
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 
35 #include <ignition/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 
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 
163  public: void CreateCone(const std::string &_name,
164  const float _radius,
165  const float _height,
166  const int _rings,
167  const int _segments);
168 
180  public: void CreateTube(const std::string &_name,
181  const float _innerRadius,
182  const float _outterRadius,
183  const float _height,
184  const int _rings,
185  const int _segments,
186  const double _arc = 2.0 * IGN_PI);
187 
193  public: void CreatePlane(const std::string &_name,
194  const ignition::math::Planed &_plane,
195  const ignition::math::Vector2d &_segments,
196  const ignition::math::Vector2d &_uvTile);
197 
205  public: void CreatePlane(const std::string &_name,
206  const ignition::math::Vector3d &_normal,
207  const double _d,
208  const ignition::math::Vector2d &_size,
209  const ignition::math::Vector2d &_segments,
210  const ignition::math::Vector2d &_uvTile);
211 
219  private: void Tesselate2DMesh(SubMesh *_sm,
220  const int _meshWidth,
221  const int _meshHeight,
222  const bool _doubleSided);
223 
227  public: void CreateCamera(const std::string &_name, const float _scale);
228 
235  public: void CreateBoolean(const std::string &_name, const Mesh *_m1,
236  const Mesh *_m2, const int _operation,
238 
246  private: static void ConvertPolylinesToVerticesAndEdges(
248  &_polys,
249  const double _tol,
252 
260  private: static size_t AddUniquePointToVerticesTable(
262  const ignition::math::Vector2d &_p,
263  const double _tol);
264 
267  private: std::unique_ptr<MeshManagerPrivate> dataPtr;
269 
271  private: friend class SingletonT<MeshManager>;
272  };
273  }
274 }
275 #endif
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
static const Pose3< T > Zero
STL class.
A child mesh.
Definition: SubMesh.hh:40
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
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64
A 3D mesh.
Definition: Mesh.hh:41