Ignition Rendering

API Reference

0.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  template <class T>
29  class IGNITION_RENDERING_VISIBLE BaseGeometry :
30  public virtual Geometry,
31  public virtual T
32  {
33  protected: BaseGeometry();
34 
35  public: virtual ~BaseGeometry();
36 
37  public: virtual VisualPtr Parent() const = 0;
38 
39  public: virtual void RemoveParent();
40 
41  public: virtual void SetMaterial(const std::string &_name,
42  bool unique = true);
43 
44  public: virtual void SetMaterial(MaterialPtr _material,
45  bool unique = true) = 0;
46 
47  public: virtual void Destroy();
48  };
49 
51  template <class T>
53  {
54  }
55 
57  template <class T>
59  {
60  }
61 
63  template <class T>
65  {
66  VisualPtr parent = this->Parent();
67 
68  if (parent)
69  {
70  auto baseShared = this->shared_from_this();
71 
72  auto thisShared =
74 
75  parent->RemoveGeometry(thisShared);
76  }
77  }
78 
80  template <class T>
81  void BaseGeometry<T>::SetMaterial(const std::string &_name, bool _unique)
82  {
83  MaterialPtr material = this->Scene()->Material(_name);
84  if (material) this->SetMaterial(material, _unique);
85  }
86 
88  template <class T>
90  {
91  T::Destroy();
92  this->RemoveParent();
93  }
94  }
95 }
96 #endif
virtual void RemoveParent()
Detach this Geometry from its parent Visual. If this Geometry does not have a parent, no work will be done.
Definition: BaseGeometry.hh:64
STL class.
BaseGeometry()
Definition: BaseGeometry.hh:52
Manages a single scene-graph. This class updates scene-wide properties and holds the root scene node...
Definition: Scene.hh:44
virtual void Destroy()
Destroy any resources associated with this object. Invoking any other functions after destroying an o...
Definition: BaseGeometry.hh:89
T dynamic_pointer_cast(T... args)
Definition: BaseGeometry.hh:29
virtual void SetMaterial(const std::string &_name, bool unique=true)
Set the materials of this Geometry. The specified material will be retrieved from the parent Scene...
Definition: BaseGeometry.hh:81
Definition: ArrowVisual.hh:22
Represents a geometric shape to be rendered.
Definition: Geometry.hh:31
virtual ~BaseGeometry()
Definition: BaseGeometry.hh:58
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...