Ignition Rendering

API Reference

5.1.0
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 IGNITION_RENDERING_BASE_BASEGEOMETRY_HH_
18 #define IGNITION_RENDERING_BASE_BASEGEOMETRY_HH_
19 
20 #include <string>
23 
24 namespace ignition
25 {
26  namespace rendering
27  {
28  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
29  //
30  template <class T>
31  class BaseGeometry :
32  public virtual Geometry,
33  public virtual T
34  {
35  protected: BaseGeometry();
36 
37  public: virtual ~BaseGeometry();
38 
39  public: virtual VisualPtr Parent() const override = 0;
40 
41  public: virtual void RemoveParent() override;
42 
43  // Documentation inherited
44  public: virtual void SetMaterial(const std::string &_material,
45  bool _unique = true) override;
46 
47  // Documentation inherited
48  public: virtual void SetMaterial(MaterialPtr _material,
49  bool _unique = true) override = 0;
50 
51  // Documentation inherited
52  public: virtual void Destroy() override;
53  };
54 
56  template <class T>
58  {
59  }
60 
62  template <class T>
64  {
65  }
66 
68  template <class T>
70  {
71  VisualPtr parent = this->Parent();
72 
73  if (parent)
74  {
75  auto baseShared = this->shared_from_this();
76 
77  auto thisShared =
79 
80  parent->RemoveGeometry(thisShared);
81  }
82  }
83 
85  template <class T>
86  void BaseGeometry<T>::SetMaterial(const std::string &_name, bool _unique)
87  {
88  MaterialPtr material = this->Scene()->Material(_name);
89  if (material) this->SetMaterial(material, _unique);
90  }
91 
93  template <class T>
95  {
96  T::Destroy();
97  this->RemoveParent();
98  }
99  }
100  }
101 }
102 #endif
virtual void SetMaterial(const std::string &_material, bool _unique=true) override
Set the materials of this Geometry. The specified material will be retrieved from the parent Scene...
Definition: BaseGeometry.hh:86
STL class.
BaseGeometry()
Definition: BaseGeometry.hh:57
Manages a single scene-graph. This class updates scene-wide properties and holds the root scene node...
Definition: Scene.hh:49
T dynamic_pointer_cast(T... args)
virtual void RemoveParent() override
Detach this Geometry from its parent Visual. If this Geometry does not have a parent, no work will be done.
Definition: BaseGeometry.hh:69
Definition: BaseGeometry.hh:31
Represents a geometric shape to be rendered.
Definition: Geometry.hh:34
virtual void Destroy() override
Destroy any resources associated with this object. Invoking any other functions after destroying an o...
Definition: BaseGeometry.hh:94
virtual ~BaseGeometry()
Definition: BaseGeometry.hh:63
virtual MaterialPtr Material(const std::string &_name) const =0
Get material registered under the given name. If no material is registered under the given name...