Skip to content

Commit

Permalink
Added code suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: William Lew <WilliamMilesLew@gmail.com>
  • Loading branch information
WilliamLewww committed Jan 25, 2022
1 parent 930f215 commit 65e9243
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
7 changes: 4 additions & 3 deletions include/ignition/sensors/BrownDistortionModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@

#include <sdf/sdf.hh>

#include "ignition/sensors/config.hh"
#include "ignition/sensors/Export.hh"
#include "ignition/sensors/Distortion.hh"
#include "ignition/sensors/Export.hh"
#include "ignition/sensors/config.hh"
#include "ignition/utils/ImplPtr.hh"

namespace ignition
{
Expand Down Expand Up @@ -77,7 +78,7 @@ namespace ignition
public: virtual void Print(std::ostream &_out) const override;

/// \brief Private data pointer.
private: BrownDistortionModelPrivate *dataPtr = nullptr;
IGN_UTILS_IMPL_PTR(dataPtr)
};
}
}
Expand Down
7 changes: 4 additions & 3 deletions include/ignition/sensors/Distortion.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
#include <string>
#include <vector>

#include <ignition/sensors/config.hh>
#include <ignition/sensors/SensorTypes.hh>
#include <ignition/sensors/Export.hh>
#include <ignition/sensors/SensorTypes.hh>
#include <ignition/sensors/config.hh>
#include <ignition/utils/ImplPtr.hh>

#include <sdf/sdf.hh>

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

/// \brief Private data pointer
private: DistortionPrivate *dataPtr = nullptr;
IGN_UTILS_IMPL_PTR(dataPtr)
};
}
}
Expand Down
20 changes: 9 additions & 11 deletions src/BrownDistortionModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
#endif

#include "ignition/sensors/BrownDistortionModel.hh"

#include <ignition/common/Console.hh>
#include <ignition/math/Helpers.hh>
#include <ignition/math/Rand.hh>

#include "ignition/common/Console.hh"

using namespace ignition;
using namespace sensors;

class ignition::sensors::BrownDistortionModelPrivate
class ignition::sensors::BrownDistortionModel::Implementation
{
/// \brief The radial distortion coefficient k1.
public: double k1 = 0.0;
Expand All @@ -53,15 +53,13 @@ class ignition::sensors::BrownDistortionModelPrivate
//////////////////////////////////////////////////
BrownDistortionModel::BrownDistortionModel()
: Distortion(DistortionType::BROWN),
dataPtr(new BrownDistortionModelPrivate())
dataPtr(utils::MakeImpl<Implementation>())
{
}

//////////////////////////////////////////////////
BrownDistortionModel::~BrownDistortionModel()
{
delete this->dataPtr;
this->dataPtr = nullptr;
}

//////////////////////////////////////////////////
Expand Down Expand Up @@ -117,9 +115,9 @@ math::Vector2d BrownDistortionModel::Center() const
void BrownDistortionModel::Print(std::ostream &_out) const
{
_out << "Distortion, k1[" << this->dataPtr->k1 << "], "
<< "k2[" << this->dataPtr->k2 << "] "
<< "k3[" << this->dataPtr->k2 << "] "
<< "p1[" << this->dataPtr->p1 << "] "
<< "p2[" << this->dataPtr->p2 << "] "
<< "lensCenter[" << this->dataPtr->lensCenter << "]";
<< "k2[" << this->dataPtr->k2 << "] "
<< "k3[" << this->dataPtr->k2 << "] "
<< "p1[" << this->dataPtr->p1 << "] "
<< "p2[" << this->dataPtr->p2 << "] "
<< "lensCenter[" << this->dataPtr->lensCenter << "]";
}
12 changes: 5 additions & 7 deletions src/Distortion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
using namespace ignition;
using namespace sensors;

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

//////////////////////////////////////////////////
Distortion::Distortion(DistortionType _type)
: dataPtr(new DistortionPrivate())
: dataPtr(utils::MakeImpl<Implementation>())
{
this->dataPtr->type = _type;
}

//////////////////////////////////////////////////
Distortion::~Distortion()
{
delete this->dataPtr;
this->dataPtr = nullptr;
}

//////////////////////////////////////////////////
Expand All @@ -130,7 +128,7 @@ DistortionType Distortion::Type() const
void Distortion::Print(std::ostream &_out) const
{
_out << "Distortion with type[" << static_cast<int>(this->dataPtr->type)
<< "] "
<< "does not have an overloaded Print function. "
<< "No more information is available.";
<< "] "
<< "does not have an overloaded Print function. "
<< "No more information is available.";
}
12 changes: 6 additions & 6 deletions src/ImageBrownDistortionModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#pragma warning(disable: 4251)
#endif
#include <ignition/rendering/DistortionPass.hh>
#include <ignition/rendering/RenderPass.hh>
#include <ignition/rendering/RenderEngine.hh>
#include <ignition/rendering/RenderPass.hh>
#include <ignition/rendering/RenderPassSystem.hh>
#ifdef _WIN32
#pragma warning(pop)
Expand Down Expand Up @@ -124,9 +124,9 @@ void ImageBrownDistortionModel::SetCamera(rendering::CameraPtr _camera)
void ImageBrownDistortionModel::Print(std::ostream &_out) const
{
_out << "Image distortion, k1[" << this->dataPtr->k1 << "], "
<< "k2[" << this->dataPtr->k2 << "] "
<< "k3[" << this->dataPtr->k2 << "] "
<< "p1[" << this->dataPtr->p1 << "] "
<< "p2[" << this->dataPtr->p2 << "] "
<< "lensCenter[" << this->dataPtr->lensCenter << "]";
<< "k2[" << this->dataPtr->k2 << "] "
<< "k3[" << this->dataPtr->k2 << "] "
<< "p1[" << this->dataPtr->p1 << "] "
<< "p2[" << this->dataPtr->p2 << "] "
<< "lensCenter[" << this->dataPtr->lensCenter << "]";
}

0 comments on commit 65e9243

Please sign in to comment.