Ignition Rendering

API Reference

6.3.1
BaseCapsule.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 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 
18 #ifndef IGNITION_RENDERING_BASECAPSULE_HH_
19 #define IGNITION_RENDERING_BASECAPSULE_HH_
20 
22 
26 
27 namespace ignition
28 {
29  namespace rendering
30  {
31  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
33  template <class T>
34  class BaseCapsule :
35  public virtual Capsule,
36  public virtual T
37  {
38  // Documentation inherited
39  protected: BaseCapsule();
40 
41  // Documentation inherited
42  public: virtual ~BaseCapsule();
43 
44  // Documentation inherited
45  public: virtual void SetRadius(double _radius) override;
46 
47  // Documentation inherited
48  public: virtual void SetLength(double _length) override;
49 
50  // Documentation inherited
51  public: virtual double Radius() const override;
52 
53  // Documentation inherited
54  public: virtual double Length() const override;
55 
56  // Documentation inherited
57  public: virtual GeometryPtr Clone() const override;
58 
60  protected: double radius = 0.5;
61 
63  protected: double length = 0.5;
64 
66  protected: bool capsuleDirty = false;
67  };
68 
70  // BaseCapsule
72  template <class T>
74  {
75  }
76 
78  template <class T>
80  {
81  }
82 
84  template <class T>
85  void BaseCapsule<T>::SetRadius(double _radius)
86  {
87  this->radius = _radius;
88  this->capsuleDirty = true;
89  }
90 
92  template <class T>
93  double BaseCapsule<T>::Radius() const
94  {
95  return this->radius;
96  }
97 
99  template <class T>
100  void BaseCapsule<T>::SetLength(double _length)
101  {
102  this->length = _length;
103  this->capsuleDirty = true;
104  }
105 
107  template <class T>
108  double BaseCapsule<T>::Length() const
109  {
110  return this->length;
111  }
112 
114  template <class T>
116  {
117  if (!this->Scene())
118  {
119  ignerr << "Cloning a Capsule failed because the capsule to be "
120  << "cloned does not belong to a scene.\n";
121  return nullptr;
122  }
123 
124  auto result = this->Scene()->CreateCapsule();
125  if (result)
126  {
127  result->SetRadius(this->Radius());
128  result->SetLength(this->Length());
129 
130  if (this->Material())
131  result->SetMaterial(this->Material());
132  }
133 
134  return result;
135  }
136  }
137  }
138 }
139 #endif
virtual ~BaseCapsule()
Definition: BaseCapsule.hh:79
Geometry for a capsule shape.
Definition: Capsule.hh:32
virtual double Radius() const override
Get the radius of the capsule.
Definition: BaseCapsule.hh:93
BaseCapsule()
Definition: BaseCapsule.hh:73
virtual void SetRadius(double _radius) override
Set the radius of the capsule.
Definition: BaseCapsule.hh:85
Base implementation of a Capsule Geometry.
Definition: BaseCapsule.hh:34
virtual double Length() const override
Get the length of the capsule.
Definition: BaseCapsule.hh:108
Manages a single scene-graph. This class updates scene-wide properties and holds the root scene node...
Definition: Scene.hh:49
virtual GeometryPtr Clone() const override
Clone the geometry.
Definition: BaseCapsule.hh:115
virtual void SetLength(double _length) override
Set the length of the capsule.
Definition: BaseCapsule.hh:100
#define ignerr
virtual CapsulePtr CreateCapsule()=0
Create new capsule geometry.
Represents a surface material of a Geometry.
Definition: Material.hh:47