Skip to content

Commit 65e9243

Browse files
committed
Added code suggestions
Signed-off-by: William Lew <WilliamMilesLew@gmail.com>
1 parent 930f215 commit 65e9243

File tree

5 files changed

+28
-30
lines changed

5 files changed

+28
-30
lines changed

include/ignition/sensors/BrownDistortionModel.hh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020

2121
#include <sdf/sdf.hh>
2222

23-
#include "ignition/sensors/config.hh"
24-
#include "ignition/sensors/Export.hh"
2523
#include "ignition/sensors/Distortion.hh"
24+
#include "ignition/sensors/Export.hh"
25+
#include "ignition/sensors/config.hh"
26+
#include "ignition/utils/ImplPtr.hh"
2627

2728
namespace ignition
2829
{
@@ -77,7 +78,7 @@ namespace ignition
7778
public: virtual void Print(std::ostream &_out) const override;
7879

7980
/// \brief Private data pointer.
80-
private: BrownDistortionModelPrivate *dataPtr = nullptr;
81+
IGN_UTILS_IMPL_PTR(dataPtr)
8182
};
8283
}
8384
}

include/ignition/sensors/Distortion.hh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
#include <string>
2323
#include <vector>
2424

25-
#include <ignition/sensors/config.hh>
26-
#include <ignition/sensors/SensorTypes.hh>
2725
#include <ignition/sensors/Export.hh>
26+
#include <ignition/sensors/SensorTypes.hh>
27+
#include <ignition/sensors/config.hh>
28+
#include <ignition/utils/ImplPtr.hh>
2829

2930
#include <sdf/sdf.hh>
3031

@@ -99,7 +100,7 @@ namespace ignition
99100
public: virtual void Print(std::ostream &_out) const;
100101

101102
/// \brief Private data pointer
102-
private: DistortionPrivate *dataPtr = nullptr;
103+
IGN_UTILS_IMPL_PTR(dataPtr)
103104
};
104105
}
105106
}

src/BrownDistortionModel.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
#endif
2222

2323
#include "ignition/sensors/BrownDistortionModel.hh"
24+
25+
#include <ignition/common/Console.hh>
2426
#include <ignition/math/Helpers.hh>
2527
#include <ignition/math/Rand.hh>
2628

27-
#include "ignition/common/Console.hh"
28-
2929
using namespace ignition;
3030
using namespace sensors;
3131

32-
class ignition::sensors::BrownDistortionModelPrivate
32+
class ignition::sensors::BrownDistortionModel::Implementation
3333
{
3434
/// \brief The radial distortion coefficient k1.
3535
public: double k1 = 0.0;
@@ -53,15 +53,13 @@ class ignition::sensors::BrownDistortionModelPrivate
5353
//////////////////////////////////////////////////
5454
BrownDistortionModel::BrownDistortionModel()
5555
: Distortion(DistortionType::BROWN),
56-
dataPtr(new BrownDistortionModelPrivate())
56+
dataPtr(utils::MakeImpl<Implementation>())
5757
{
5858
}
5959

6060
//////////////////////////////////////////////////
6161
BrownDistortionModel::~BrownDistortionModel()
6262
{
63-
delete this->dataPtr;
64-
this->dataPtr = nullptr;
6563
}
6664

6765
//////////////////////////////////////////////////
@@ -117,9 +115,9 @@ math::Vector2d BrownDistortionModel::Center() const
117115
void BrownDistortionModel::Print(std::ostream &_out) const
118116
{
119117
_out << "Distortion, k1[" << this->dataPtr->k1 << "], "
120-
<< "k2[" << this->dataPtr->k2 << "] "
121-
<< "k3[" << this->dataPtr->k2 << "] "
122-
<< "p1[" << this->dataPtr->p1 << "] "
123-
<< "p2[" << this->dataPtr->p2 << "] "
124-
<< "lensCenter[" << this->dataPtr->lensCenter << "]";
118+
<< "k2[" << this->dataPtr->k2 << "] "
119+
<< "k3[" << this->dataPtr->k2 << "] "
120+
<< "p1[" << this->dataPtr->p1 << "] "
121+
<< "p2[" << this->dataPtr->p2 << "] "
122+
<< "lensCenter[" << this->dataPtr->lensCenter << "]";
125123
}

src/Distortion.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
using namespace ignition;
3232
using namespace sensors;
3333

34-
class ignition::sensors::DistortionPrivate
34+
class ignition::sensors::Distortion::Implementation
3535
{
3636
/// \brief Which type of distortion we're applying
3737
public: DistortionType type = DistortionType::NONE;
@@ -102,16 +102,14 @@ DistortionPtr DistortionFactory::NewDistortionModel(sdf::ElementPtr _sdf,
102102

103103
//////////////////////////////////////////////////
104104
Distortion::Distortion(DistortionType _type)
105-
: dataPtr(new DistortionPrivate())
105+
: dataPtr(utils::MakeImpl<Implementation>())
106106
{
107107
this->dataPtr->type = _type;
108108
}
109109

110110
//////////////////////////////////////////////////
111111
Distortion::~Distortion()
112112
{
113-
delete this->dataPtr;
114-
this->dataPtr = nullptr;
115113
}
116114

117115
//////////////////////////////////////////////////
@@ -130,7 +128,7 @@ DistortionType Distortion::Type() const
130128
void Distortion::Print(std::ostream &_out) const
131129
{
132130
_out << "Distortion with type[" << static_cast<int>(this->dataPtr->type)
133-
<< "] "
134-
<< "does not have an overloaded Print function. "
135-
<< "No more information is available.";
131+
<< "] "
132+
<< "does not have an overloaded Print function. "
133+
<< "No more information is available.";
136134
}

src/ImageBrownDistortionModel.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#pragma warning(disable: 4251)
3030
#endif
3131
#include <ignition/rendering/DistortionPass.hh>
32-
#include <ignition/rendering/RenderPass.hh>
3332
#include <ignition/rendering/RenderEngine.hh>
33+
#include <ignition/rendering/RenderPass.hh>
3434
#include <ignition/rendering/RenderPassSystem.hh>
3535
#ifdef _WIN32
3636
#pragma warning(pop)
@@ -124,9 +124,9 @@ void ImageBrownDistortionModel::SetCamera(rendering::CameraPtr _camera)
124124
void ImageBrownDistortionModel::Print(std::ostream &_out) const
125125
{
126126
_out << "Image distortion, k1[" << this->dataPtr->k1 << "], "
127-
<< "k2[" << this->dataPtr->k2 << "] "
128-
<< "k3[" << this->dataPtr->k2 << "] "
129-
<< "p1[" << this->dataPtr->p1 << "] "
130-
<< "p2[" << this->dataPtr->p2 << "] "
131-
<< "lensCenter[" << this->dataPtr->lensCenter << "]";
127+
<< "k2[" << this->dataPtr->k2 << "] "
128+
<< "k3[" << this->dataPtr->k2 << "] "
129+
<< "p1[" << this->dataPtr->p1 << "] "
130+
<< "p2[" << this->dataPtr->p2 << "] "
131+
<< "lensCenter[" << this->dataPtr->lensCenter << "]";
132132
}

0 commit comments

Comments
 (0)