Ignition Common

API Reference

3.5.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 
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 
63  public: const Mesh *Load(const std::string &_filename);
64 
71  public: void Export(const Mesh *_mesh, const std::string &_filename,
72  const std::string &_extension, bool _exportTextures = false);
73 
76  public: bool IsValidFilename(const std::string &_filename);
77 
83  public: void MeshAABB(const Mesh *_mesh,
84  ignition::math::Vector3d &_center,
85  ignition::math::Vector3d &_min_xyz,
86  ignition::math::Vector3d &_max_xyz);
87 
91  public: void GenSphericalTexCoord(const Mesh *_mesh,
92  const ignition::math::Vector3d &_center);
93 
99  public: void AddMesh(Mesh *_mesh);
100 
104  public: const ignition::common::Mesh *MeshByName(
105  const std::string &_name) const;
106 
109  public: bool HasMesh(const std::string &_name) const;
110 
116  public: void CreateSphere(const std::string &_name, const float _radius,
117  const int _rings, const int _segments);
118 
123  public: void CreateBox(const std::string &_name,
124  const ignition::math::Vector3d &_sides,
125  const ignition::math::Vector2d &_uvCoords);
126 
139  public: void CreateExtrudedPolyline(const std::string &_name,
141  &_vertices, const double _height);
142 
149  public: void CreateCylinder(const std::string &_name,
150  const float _radius,
151  const float _height,
152  const int _rings,
153  const int _segments);
154 
161  public: void CreateCone(const std::string &_name,
162  const float _radius,
163  const float _height,
164  const int _rings,
165  const int _segments);
166 
178  public: void CreateTube(const std::string &_name,
179  const float _innerRadius,
180  const float _outterRadius,
181  const float _height,
182  const int _rings,
183  const int _segments,
184  const double _arc = 2.0 * IGN_PI);
185 
191  public: void CreatePlane(const std::string &_name,
192  const ignition::math::Planed &_plane,
193  const ignition::math::Vector2d &_segments,
194  const ignition::math::Vector2d &_uvTile);
195 
203  public: void CreatePlane(const std::string &_name,
204  const ignition::math::Vector3d &_normal,
205  const double _d,
206  const ignition::math::Vector2d &_size,
207  const ignition::math::Vector2d &_segments,
208  const ignition::math::Vector2d &_uvTile);
209 
217  private: void Tesselate2DMesh(SubMesh *_sm,
218  const int _meshWidth,
219  const int _meshHeight,
220  const bool _doubleSided);
221 
225  public: void CreateCamera(const std::string &_name, const float _scale);
226 
233  public: void CreateBoolean(const std::string &_name, const Mesh *_m1,
234  const Mesh *_m2, const int _operation,
236 
244  private: static void ConvertPolylinesToVerticesAndEdges(
246  &_polys,
247  const double _tol,
250 
258  private: static size_t AddUniquePointToVerticesTable(
260  const ignition::math::Vector2d &_p,
261  const double _tol);
262 
265  private: std::unique_ptr<MeshManagerPrivate> dataPtr;
267 
269  private: friend class SingletonT<MeshManager>;
270  };
271  }
272 }
273 #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