Skip to content

Commit

Permalink
fix missing standard includes
Browse files Browse the repository at this point in the history
  • Loading branch information
aPonza committed Mar 16, 2020
1 parent f349f93 commit fa9dd09
Show file tree
Hide file tree
Showing 21 changed files with 512 additions and 477 deletions.
15 changes: 8 additions & 7 deletions common/include/pcl/common/bivariate_polynomial.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@

#include <fstream>
#include <iostream>
#include <vector>

namespace pcl
namespace pcl
{
/** \brief This represents a bivariate polynomial and provides some functionality for it
* \author Bastian Steder
* \author Bastian Steder
* \ingroup common
*/
template<typename real>
class BivariatePolynomialT
class BivariatePolynomialT
{
public:
//-----CONSTRUCTOR&DESTRUCTOR-----
Expand All @@ -76,7 +77,7 @@ namespace pcl

/** Calculate the value of the polynomial at the given point */
real
getValue (real x, real y) const;
getValue (real x, real y) const;

/** Calculate the gradient of this polynomial
* If forceRecalc is false, it will do nothing when the gradient already exists */
Expand All @@ -91,7 +92,7 @@ namespace pcl
* !!Currently only implemented for degree 2!! */
void
findCriticalPoints (std::vector<real>& x_values, std::vector<real>& y_values, std::vector<int>& types) const;

/** write as binary to a stream */
void
writeBinary (std::ostream& os) const;
Expand All @@ -107,7 +108,7 @@ namespace pcl
/** read binary from a file */
void
readBinary (const char* filename);

/** How many parameters has a bivariate polynomial of the given degree */
static unsigned int
getNoOfParametersFromDegree (int n) { return ((n+2)* (n+1))/2;}
Expand All @@ -116,7 +117,7 @@ namespace pcl
int degree;
real* parameters;
BivariatePolynomialT<real>* gradient_x, * gradient_y;

protected:
//-----METHODS-----
/** Delete all members */
Expand Down
47 changes: 26 additions & 21 deletions common/include/pcl/common/impl/bivariate_polynomial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
#define BIVARIATE_POLYNOMIAL_HPP

#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <istream>
#include <ostream>
#include <vector>

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<typename real>
Expand Down Expand Up @@ -99,26 +105,26 @@ template<typename real> void
pcl::BivariatePolynomialT<real>::deepCopy (const pcl::BivariatePolynomialT<real>& other)
{
if (this == &other) return;
if (degree != other.degree)
if (degree != other.degree)
{
memoryCleanUp ();
degree = other.degree;
parameters = new real[getNoOfParameters ()];
}
if (other.gradient_x == NULL)
if (other.gradient_x == NULL)
{
delete gradient_x; gradient_x=NULL;
delete gradient_y; gradient_y=NULL;
}
else if (gradient_x==NULL)
else if (gradient_x==NULL)
{
gradient_x = new pcl::BivariatePolynomialT<real> ();
gradient_y = new pcl::BivariatePolynomialT<real> ();
}

std::copy_n(other.parameters, getNoOfParameters (), parameters);

if (other.gradient_x != NULL)
if (other.gradient_x != NULL)
{
gradient_x->deepCopy (*other.gradient_x);
gradient_y->deepCopy (*other.gradient_y);
Expand All @@ -130,23 +136,23 @@ template<typename real> void
pcl::BivariatePolynomialT<real>::calculateGradient (bool forceRecalc)
{
if (gradient_x!=NULL && !forceRecalc) return;

if (gradient_x == NULL)
gradient_x = new pcl::BivariatePolynomialT<real> (degree-1);
if (gradient_y == NULL)
gradient_y = new pcl::BivariatePolynomialT<real> (degree-1);

unsigned int parameterPosDx=0, parameterPosDy=0;
for (int xDegree=degree; xDegree>=0; xDegree--)
for (int xDegree=degree; xDegree>=0; xDegree--)
{
for (int yDegree=degree-xDegree; yDegree>=0; yDegree--)
for (int yDegree=degree-xDegree; yDegree>=0; yDegree--)
{
if (xDegree > 0)
if (xDegree > 0)
{
gradient_x->parameters[parameterPosDx] = xDegree * parameters[parameterPosDx];
parameterPosDx++;
}
if (yDegree > 0)
if (yDegree > 0)
{
gradient_y->parameters[parameterPosDy] = yDegree * parameters[ ( (degree+2-xDegree)* (degree+1-xDegree))/2 -
yDegree - 1];
Expand All @@ -163,7 +169,7 @@ pcl::BivariatePolynomialT<real>::getValue (real x, real y) const
unsigned int parametersSize = getNoOfParameters ();
real* tmpParameter = &parameters[parametersSize-1];
real tmpX=1.0, tmpY, ret=0;
for (int xDegree=0; xDegree<=degree; xDegree++)
for (int xDegree=0; xDegree<=degree; xDegree++)
{
tmpY = 1.0;
for (int yDegree=0; yDegree<=degree-xDegree; yDegree++)
Expand Down Expand Up @@ -194,16 +200,16 @@ pcl::BivariatePolynomialT<real>::findCriticalPoints (std::vector<real>& x_values
x_values.clear ();
y_values.clear ();
types.clear ();

if (degree == 2)
{
real x = (real(2)*parameters[2]*parameters[3] - parameters[1]*parameters[4]) /
(parameters[1]*parameters[1] - real(4)*parameters[0]*parameters[3]),
y = (real(-2)*parameters[0]*x - parameters[2]) / parameters[1];

if (!std::isfinite(x) || !std::isfinite(y))
return;

int type = 2;
real det_H = real(4)*parameters[0]*parameters[3] - parameters[1]*parameters[1];
//std::cout << "det(H) = "<<det_H<<"\n";
Expand Down Expand Up @@ -231,30 +237,30 @@ pcl::operator<< (std::ostream& os, const pcl::BivariatePolynomialT<real>& p)
real* tmpParameter = p.parameters;
bool first = true;
real currentParameter;
for (int xDegree=p.degree; xDegree>=0; xDegree--)
for (int xDegree=p.degree; xDegree>=0; xDegree--)
{
for (int yDegree=p.degree-xDegree; yDegree>=0; yDegree--)
for (int yDegree=p.degree-xDegree; yDegree>=0; yDegree--)
{
currentParameter = *tmpParameter;
if (!first)
if (!first)
{
os << (currentParameter<0.0?" - ":" + ");
currentParameter = std::abs (currentParameter);
}
os << currentParameter;
if (xDegree>0)
if (xDegree>0)
{
os << "x";
if (xDegree>1)
os<<"^"<<xDegree;
}
if (yDegree>0)
if (yDegree>0)
{
os << "y";
if (yDegree>1)
os<<"^"<<yDegree;
}

first = false;
tmpParameter++;
}
Expand Down Expand Up @@ -299,4 +305,3 @@ pcl::BivariatePolynomialT<real>::readBinary (const char* filename)
}

#endif

57 changes: 28 additions & 29 deletions common/include/pcl/common/impl/eigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#include <array>
#include <algorithm>

#include <cmath>
#include <pcl/console/print.h>

//////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -493,24 +493,24 @@ pcl::determinant3x3Matrix (const Matrix& matrix)
}

//////////////////////////////////////////////////////////////////////////////////////////
void
pcl::getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis,
const Eigen::Vector3f& y_direction,
void
pcl::getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis,
const Eigen::Vector3f& y_direction,
Eigen::Affine3f& transformation)
{
Eigen::Vector3f tmp0 = (y_direction.cross(z_axis)).normalized();
Eigen::Vector3f tmp1 = (z_axis.cross(tmp0)).normalized();
Eigen::Vector3f tmp2 = z_axis.normalized();

transformation(0,0)=tmp0[0]; transformation(0,1)=tmp0[1]; transformation(0,2)=tmp0[2]; transformation(0,3)=0.0f;
transformation(1,0)=tmp1[0]; transformation(1,1)=tmp1[1]; transformation(1,2)=tmp1[2]; transformation(1,3)=0.0f;
transformation(2,0)=tmp2[0]; transformation(2,1)=tmp2[1]; transformation(2,2)=tmp2[2]; transformation(2,3)=0.0f;
transformation(3,0)=0.0f; transformation(3,1)=0.0f; transformation(3,2)=0.0f; transformation(3,3)=1.0f;
}

//////////////////////////////////////////////////////////////////////////////////////////
Eigen::Affine3f
pcl::getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis,
Eigen::Affine3f
pcl::getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis,
const Eigen::Vector3f& y_direction)
{
Eigen::Affine3f transformation;
Expand All @@ -519,24 +519,24 @@ pcl::getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis,
}

//////////////////////////////////////////////////////////////////////////////////////////
void
pcl::getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis,
const Eigen::Vector3f& y_direction,
void
pcl::getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis,
const Eigen::Vector3f& y_direction,
Eigen::Affine3f& transformation)
{
Eigen::Vector3f tmp2 = (x_axis.cross(y_direction)).normalized();
Eigen::Vector3f tmp1 = (tmp2.cross(x_axis)).normalized();
Eigen::Vector3f tmp0 = x_axis.normalized();

transformation(0,0)=tmp0[0]; transformation(0,1)=tmp0[1]; transformation(0,2)=tmp0[2]; transformation(0,3)=0.0f;
transformation(1,0)=tmp1[0]; transformation(1,1)=tmp1[1]; transformation(1,2)=tmp1[2]; transformation(1,3)=0.0f;
transformation(2,0)=tmp2[0]; transformation(2,1)=tmp2[1]; transformation(2,2)=tmp2[2]; transformation(2,3)=0.0f;
transformation(3,0)=0.0f; transformation(3,1)=0.0f; transformation(3,2)=0.0f; transformation(3,3)=1.0f;
}

//////////////////////////////////////////////////////////////////////////////////////////
Eigen::Affine3f
pcl::getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis,
Eigen::Affine3f
pcl::getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis,
const Eigen::Vector3f& y_direction)
{
Eigen::Affine3f transformation;
Expand All @@ -545,28 +545,28 @@ pcl::getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis,
}

//////////////////////////////////////////////////////////////////////////////////////////
void
pcl::getTransformationFromTwoUnitVectors (const Eigen::Vector3f& y_direction,
const Eigen::Vector3f& z_axis,
void
pcl::getTransformationFromTwoUnitVectors (const Eigen::Vector3f& y_direction,
const Eigen::Vector3f& z_axis,
Eigen::Affine3f& transformation)
{
getTransFromUnitVectorsZY (z_axis, y_direction, transformation);
}

//////////////////////////////////////////////////////////////////////////////////////////
Eigen::Affine3f
pcl::getTransformationFromTwoUnitVectors (const Eigen::Vector3f& y_direction,
Eigen::Affine3f
pcl::getTransformationFromTwoUnitVectors (const Eigen::Vector3f& y_direction,
const Eigen::Vector3f& z_axis)
{
Eigen::Affine3f transformation;
getTransformationFromTwoUnitVectors (y_direction, z_axis, transformation);
return (transformation);
}

void
pcl::getTransformationFromTwoUnitVectorsAndOrigin (const Eigen::Vector3f& y_direction,
void
pcl::getTransformationFromTwoUnitVectorsAndOrigin (const Eigen::Vector3f& y_direction,
const Eigen::Vector3f& z_axis,
const Eigen::Vector3f& origin,
const Eigen::Vector3f& origin,
Eigen::Affine3f& transformation)
{
getTransformationFromTwoUnitVectors(y_direction, z_axis, transformation);
Expand Down Expand Up @@ -598,9 +598,9 @@ pcl::getTranslationAndEulerAngles (const Eigen::Transform<Scalar, 3, Eigen::Affi
}

//////////////////////////////////////////////////////////////////////////////////////////
template <typename Scalar> void
pcl::getTransformation (Scalar x, Scalar y, Scalar z,
Scalar roll, Scalar pitch, Scalar yaw,
template <typename Scalar> void
pcl::getTransformation (Scalar x, Scalar y, Scalar z,
Scalar roll, Scalar pitch, Scalar yaw,
Eigen::Transform<Scalar, 3, Eigen::Affine> &t)
{
Scalar A = std::cos (yaw), B = sin (yaw), C = std::cos (pitch), D = sin (pitch),
Expand All @@ -613,7 +613,7 @@ pcl::getTransformation (Scalar x, Scalar y, Scalar z,
}

//////////////////////////////////////////////////////////////////////////////////////////
template <typename Derived> void
template <typename Derived> void
pcl::saveBinary (const Eigen::MatrixBase<Derived>& matrix, std::ostream& file)
{
std::uint32_t rows = static_cast<std::uint32_t> (matrix.rows ()), cols = static_cast<std::uint32_t> (matrix.cols ());
Expand All @@ -628,7 +628,7 @@ pcl::saveBinary (const Eigen::MatrixBase<Derived>& matrix, std::ostream& file)
}

//////////////////////////////////////////////////////////////////////////////////////////
template <typename Derived> void
template <typename Derived> void
pcl::loadBinary (Eigen::MatrixBase<Derived> const & matrix_, std::istream& file)
{
Eigen::MatrixBase<Derived> &matrix = const_cast<Eigen::MatrixBase<Derived> &> (matrix_);
Expand All @@ -638,7 +638,7 @@ pcl::loadBinary (Eigen::MatrixBase<Derived> const & matrix_, std::istream& file)
file.read (reinterpret_cast<char*> (&cols), sizeof (cols));
if (matrix.rows () != static_cast<int>(rows) || matrix.cols () != static_cast<int>(cols))
matrix.derived().resize(rows, cols);

for (std::uint32_t i = 0; i < rows; ++i)
for (std::uint32_t j = 0; j < cols; ++j)
{
Expand All @@ -649,7 +649,7 @@ pcl::loadBinary (Eigen::MatrixBase<Derived> const & matrix_, std::istream& file)
}

//////////////////////////////////////////////////////////////////////////////////////////
template <typename Derived, typename OtherDerived>
template <typename Derived, typename OtherDerived>
typename Eigen::internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type
pcl::umeyama (const Eigen::MatrixBase<Derived>& src, const Eigen::MatrixBase<OtherDerived>& dst, bool with_scaling)
{
Expand Down Expand Up @@ -902,4 +902,3 @@ pcl::transformBetween2CoordinateSystems (const Eigen::Matrix<Scalar, Eigen::Dyna
}

#endif //PCL_COMMON_EIGEN_IMPL_HPP_

7 changes: 6 additions & 1 deletion common/include/pcl/common/impl/file_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
#include <boost/filesystem.hpp>
#include <boost/range/iterator_range.hpp>

#include <algorithm>
#include <cstddef>
#include <iostream>
#include <string>
#include <vector>

namespace pcl
{

Expand Down Expand Up @@ -88,4 +94,3 @@ std::string getFileExtension(const std::string& input)
} // namespace end

#endif

4 changes: 4 additions & 0 deletions common/include/pcl/common/impl/piecewise_linear_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

/* \author Bastian Steder */

#include <algorithm>
#include <cmath>
// #include <iostream>


namespace pcl {

Expand Down
Loading

0 comments on commit fa9dd09

Please sign in to comment.