##

MeshManager.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GAZEBO_MESHMANAGER_HH_
#define _GAZEBO_MESHMANAGER_HH_
#include <map>
#include <utility>
#include <string>
#include <vector>
#include <boost/thread/mutex.hpp>
#include <ignition/math/Plane.hh>
#include <ignition/math/Matrix3.hh>
#include <ignition/math/Matrix4.hh>
#include <ignition/math/Vector2.hh>
#include "gazebo/common/SingletonT.hh"
#include "gazebo/common/CommonTypes.hh"
#include "gazebo/util/system.hh"
GZ_SINGLETON_DECLARE(GZ_COMMON_VISIBLE, gazebo, common, MeshManager)
namespace gazebo
{
namespace common
{
class ColladaLoader;
class ColladaExporter;
class FBXLoader;
class STLLoader;
class Mesh;
class Plane;
class SubMesh;
class GZ_COMMON_VISIBLE MeshManager : public SingletonT<MeshManager>
{
private: MeshManager();
private: virtual ~MeshManager();
public: const Mesh *Load(const std::string &_filename);
public: void Export(const Mesh *_mesh, const std::string &_filename,
const std::string &_extension, bool _exportTextures = false);
public: bool IsValidFilename(const std::string &_filename);
public: void GetMeshAABB(const Mesh *_mesh,
ignition::math::Vector3d &_center,
ignition::math::Vector3d &_min_xyz,
ignition::math::Vector3d &_max_xyz);
public: void GenSphericalTexCoord(const Mesh *_mesh,
const ignition::math::Vector3d &_center);
public: void AddMesh(Mesh *_mesh);
public: const Mesh *GetMesh(const std::string &_name) const;
public: bool HasMesh(const std::string &_name) const;
public: void CreateSphere(const std::string &_name, float _radius,
int _rings, int _segments);
public: void CreateBox(const std::string &_name,
const ignition::math::Vector3d &_sides,
const ignition::math::Vector2d &_uvCoords);
public: void CreateExtrudedPolyline(const std::string &_name,
const std::vector<std::vector<ignition::math::Vector2d> >
&_vertices, double _height);
public: void CreateCylinder(const std::string &_name,
float _radius,
float _height,
int _rings,
int _segments);
public: void CreateCone(const std::string &_name,
float _radius,
float _height,
int _rings,
int _segments);
public: void CreateTube(const std::string &_name,
float _innerRadius,
float _outterRadius,
float _height,
int _rings,
int _segments,
double _arc = 2.0 * M_PI);
public: void CreatePlane(const std::string &_name,
const ignition::math::Planed &_plane,
const ignition::math::Vector2d &_segments,
const ignition::math::Vector2d &_uvTile);
public: void CreatePlane(const std::string &_name,
const ignition::math::Vector3d &_normal,
const double _d,
const ignition::math::Vector2d &_size,
const ignition::math::Vector2d &_segments,
const ignition::math::Vector2d &_uvTile);
private: void Tesselate2DMesh(SubMesh *_sm,
int _meshWidth,
int _meshHeight,
bool _doubleSided);
public: void CreateCamera(const std::string &_name, float _scale);
#ifdef HAVE_GTS
public: void CreateBoolean(const std::string &_name, const Mesh *_m1,
const Mesh *_m2, const int _operation,
const ignition::math::Pose3d &_offset = ignition::math::Pose3d::Zero);
#endif
private: static void ConvertPolylinesToVerticesAndEdges(
const std::vector<std::vector<ignition::math::Vector2d> >
&_polys,
double _tol,
std::vector<ignition::math::Vector2d> &_vertices,
std::vector<ignition::math::Vector2i> &_edges);
private: static size_t AddUniquePointToVerticesTable(
std::vector<ignition::math::Vector2d> &_vertices,
const ignition::math::Vector2d &_p,
double _tol);
private: ColladaLoader *colladaLoader = nullptr;
private: ColladaExporter *colladaExporter = nullptr;
private: STLLoader *stlLoader = nullptr;
private: FBXLoader *fbxLoader = nullptr;
private: std::map<std::string, Mesh*> meshes;
private: std::vector<std::string> fileExtensions;
private: boost::mutex mutex;
private: friend class SingletonT<MeshManager>;
};
}
}
#endif
gazebo::common::STLLoader
Class used to load STL mesh files.
Definition: STLLoader.hh:40
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
SingletonT
Singleton template class.
Definition: SingletonT.hh:33
gazebo::common::ColladaExporter
Class used to export Collada mesh files.
Definition: ColladaExporter.hh:42
system.hh
CommonTypes.hh
gazebo::common::SubMesh
A child mesh.
Definition: Mesh.hh:214
gazebo
gazebo
Definition: MeshManager.hh:36
gazebo::common::ColladaLoader
Class used to load Collada mesh files.
Definition: ColladaLoader.hh:46
common
common
Definition: MeshManager.hh:36
gazebo::common::Mesh
A 3D mesh.
Definition: Mesh.hh:42
gazebo::common::MeshManager
Maintains and manages all meshes.
Definition: MeshManager.hh:55
GZ_SINGLETON_DECLARE
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61
SingletonT.hh