Gazebo Rendering

API Reference

6.6.3
gz/rendering/base/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 
21 #include <ignition/common/Console.hh>
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
STL class.
Base implementation of a Capsule Geometry.
Definition: gz/rendering/base/BaseCapsule.hh:34
virtual double Length() const override
Get the length of the capsule.
Definition: gz/rendering/base/BaseCapsule.hh:108
bool capsuleDirty
Flag to indicate capsule properties have changed.
Definition: gz/rendering/base/BaseCapsule.hh:66
double length
Length of the capsule.
Definition: gz/rendering/base/BaseCapsule.hh:63
virtual CapsulePtr CreateCapsule()=0
Create new capsule geometry.
virtual ~BaseCapsule()
Definition: gz/rendering/base/BaseCapsule.hh:79
#define ignerr
Manages a single scene-graph. This class updates scene-wide properties and holds the root scene node....
Definition: gz/rendering/Scene.hh:49
virtual void SetRadius(double _radius) override
Set the radius of the capsule.
Definition: gz/rendering/base/BaseCapsule.hh:85
virtual double Radius() const override
Get the radius of the capsule.
Definition: gz/rendering/base/BaseCapsule.hh:93
BaseCapsule()
Definition: gz/rendering/base/BaseCapsule.hh:73
Geometry for a capsule shape.
Definition: gz/rendering/Capsule.hh:32
virtual GeometryPtr Clone() const override
Clone the geometry.
Definition: gz/rendering/base/BaseCapsule.hh:115
double radius
Radius of the capsule.
Definition: gz/rendering/base/BaseCapsule.hh:60
Represents a surface material of a Geometry.
Definition: gz/rendering/Material.hh:47
virtual void SetLength(double _length) override
Set the length of the capsule.
Definition: gz/rendering/base/BaseCapsule.hh:100