All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeshManager.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 _MESHMANAGER_HH_
18 #define _MESHMANAGER_HH_
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 #include <boost/thread/mutex.hpp>
24 
25 #include "gazebo/math/Vector3.hh"
26 #include "gazebo/math/Vector2d.hh"
27 #include "gazebo/math/Pose.hh"
28 #include "gazebo/math/Plane.hh"
30 
31 namespace gazebo
32 {
33  namespace common
34  {
35  class ColladaLoader;
36  class STLLoader;
37  class Mesh;
38  class Plane;
39  class SubMesh;
40 
43 
46  class MeshManager : public SingletonT<MeshManager>
47  {
49  private: MeshManager();
50 
54  private: virtual ~MeshManager();
55 
59  public: const Mesh *Load(const std::string &_filename);
60 
63  public: bool IsValidFilename(const std::string &_filename);
64 
70  public: void GetMeshAABB(const Mesh *_mesh,
71  math::Vector3 &_center,
72  math::Vector3 &_min_xyz,
73  math::Vector3 &_max_xyz);
74 
76  public: void GenSphericalTexCoord(const Mesh *_mesh,
77  math::Vector3 _center);
78 
79 
85  public: void AddMesh(Mesh *_mesh);
86 
90  public: const Mesh *GetMesh(const std::string &_name) const;
91 
94  public: bool HasMesh(const std::string &_name) const;
95 
101  public: void CreateSphere(const std::string &_name, float _radius,
102  int _rings, int _segments);
103 
108  public: void CreateBox(const std::string &_name,
109  const math::Vector3 &_sides,
110  const math::Vector2d &_uvCoords);
111 
118  public: void CreateCylinder(const std::string &_name,
119  float _radius,
120  float _height,
121  int _rings,
122  int _segments);
123 
130  public: void CreateCone(const std::string &_name,
131  float _radius,
132  float _height,
133  int _rings,
134  int _segments);
135 
146  public: void CreateTube(const std::string &_name,
147  float _innerRadius,
148  float _outterRadius,
149  float _height,
150  int _rings,
151  int _segments);
152 
158  public: void CreatePlane(const std::string &_name,
159  const math::Plane &_plane,
160  const math::Vector2d &_segments,
161  const math::Vector2d &_uvTile);
162 
170  public: void CreatePlane(const std::string &_name,
171  const math::Vector3 &_normal,
172  double _d,
173  const math::Vector2d &_size,
174  const math::Vector2d &_segments,
175  const math::Vector2d &_uvTile);
176 
184  private: void Tesselate2DMesh(SubMesh *_sm,
185  int _meshWidth,
186  int _meshHeight,
187  bool _doubleSided);
188 
192  public: void CreateCamera(const std::string &_name, float _scale);
193 
194 #ifdef HAVE_GTS
195 
196 
197 
198 
199 
200 
201  public: void CreateBoolean(const std::string &_name, const Mesh *_m1,
202  const Mesh *_m2, const int _operation,
203  const math::Pose &_offset = math::Pose::Zero);
204 #endif
205 
207  private: ColladaLoader *colladaLoader;
208 
210  private: STLLoader *stlLoader;
211 
213  private: std::map<std::string, Mesh*> meshes;
214 
216  private: std::vector<std::string> fileExtensions;
217 
218  private: boost::mutex mutex;
219 
221  private: friend class SingletonT<MeshManager>;
222  };
224  }
225 }
226 #endif