Gazebo Rendering

API Reference

9.0.0~pre2
BaseGeometry.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 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 GZ_RENDERING_BASE_BASEGEOMETRY_HH_
18#define GZ_RENDERING_BASE_BASEGEOMETRY_HH_
19
20#include <string>
21
22#include <gz/common/Console.hh>
23
25#include "gz/rendering/Scene.hh"
26
27namespace gz
28{
29 namespace rendering
30 {
31 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
32 //
33 template <class T>
35 public virtual Geometry,
36 public virtual T
37 {
38 protected: BaseGeometry();
39
40 public: virtual ~BaseGeometry();
41
42 public: virtual VisualPtr Parent() const override = 0;
43
44 public: virtual void RemoveParent() override;
45
46 // Documentation inherited
47 public: virtual void SetMaterial(const std::string &_material,
48 bool _unique = true) override;
49
50 // Documentation inherited
51 public: virtual void SetMaterial(MaterialPtr _material,
52 bool _unique = true) override = 0;
53
54 // Documentation inherited
55 public: virtual GeometryPtr Clone() const override;
56
57 // Documentation inherited
58 public: virtual void Destroy() override;
59 };
60
62 template <class T>
66
68 template <class T>
72
74 template <class T>
76 {
77 VisualPtr parent = this->Parent();
78
79 if (parent)
80 {
81 auto baseShared = this->shared_from_this();
82
83 auto thisShared =
85
86 parent->RemoveGeometry(thisShared);
87 }
88 }
89
91 template <class T>
92 void BaseGeometry<T>::SetMaterial(const std::string &_name, bool _unique)
93 {
94 MaterialPtr material = this->Scene()->Material(_name);
95 if (material) this->SetMaterial(material, _unique);
96 }
97
99 template <class T>
101 {
102 gzwarn << "Clone functionality for Geometry does not exist yet.\n";
103 return nullptr;
104 }
105
107 template <class T>
109 {
110 T::Destroy();
111 this->RemoveParent();
112 }
113 }
114 }
115}
116#endif