Ignition Rendering

API Reference

5.0.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  public: virtual void SetMaterial(const std::string &_name,
44  bool unique = true) override;
45 
46  public: virtual void SetMaterial(MaterialPtr _material,
47  bool unique = true) override = 0;
48 
49  // Documentation inherited
50  public: virtual void Destroy() override;
51  };
52 
54  template <class T>
56  {
57  }
58 
60  template <class T>
62  {
63  }
64 
66  template <class T>
68  {
69  VisualPtr parent = this->Parent();
70 
71  if (parent)
72  {
73  auto baseShared = this->shared_from_this();
74 
75  auto thisShared =
77 
78  parent->RemoveGeometry(thisShared);
79  }
80  }
81 
83  template <class T>
84  void BaseGeometry<T>::SetMaterial(const std::string &_name, bool _unique)
85  {
86  MaterialPtr material = this->Scene()->Material(_name);
87  if (material) this->SetMaterial(material, _unique);
88  }
89 
91  template <class T>
93  {
94  T::Destroy();
95  this->RemoveParent();
96  }
97  }
98  }
99 }
100 #endif
STL class.
BaseGeometry()
Definition: BaseGeometry.hh:55
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:67
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:92
virtual void SetMaterial(const std::string &_name, bool unique=true) override
Set the materials of this Geometry. The specified material will be retrieved from the parent Scene...
Definition: BaseGeometry.hh:84
virtual ~BaseGeometry()
Definition: BaseGeometry.hh:61
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...