Skip to content

Commit

Permalink
migrate deprecated functions into include guards
Browse files Browse the repository at this point in the history
  • Loading branch information
SamFlt committed Sep 14, 2023
1 parent c104eb1 commit 6c9a74e
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 52 deletions.
14 changes: 7 additions & 7 deletions modules/core/include/visp3/core/vpColVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
return (*this);
}

vp_deprecated double euclideanNorm() const;
/*!
Extract a sub-column vector from a column vector.
\param r : Index of the row corresponding to the first element of the
Expand All @@ -263,9 +262,9 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
{
if (r >= rowNum || r + colsize > rowNum) {
throw(vpException(vpException::fatalError,
"Cannot extract a (%dx1) column vector from a (%dx1) "
"column vector starting at index %d",
colsize, rowNum, r));
"Cannot extract a (%dx1) column vector from a (%dx1) "
"column vector starting at index %d",
colsize, rowNum, r));
}

return vpColVector(*this, r, colsize);
Expand Down Expand Up @@ -368,9 +367,9 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
{
if (ncols != 1) {
throw(vpException(vpException::fatalError,
"Cannot resize a column vector to a (%dx%d) "
"dimension vector that has more than one column",
nrows, ncols));
"Cannot resize a column vector to a (%dx%d) "
"dimension vector that has more than one column",
nrows, ncols));
}
vpArray2D<double>::resize(nrows, ncols, flagNullify);
}
Expand Down Expand Up @@ -455,6 +454,7 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
}

vp_deprecated void insert(const vpColVector &v, unsigned int r, unsigned int c = 0);
vp_deprecated double euclideanNorm() const;
//@}
#endif
};
Expand Down
22 changes: 16 additions & 6 deletions modules/core/include/visp3/core/vpMomentAreaNormalized.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class VISP_EXPORT vpMomentAreaNormalized : public vpMoment

public:
vpMomentAreaNormalized(double a_star, double Z_star);
virtual ~vpMomentAreaNormalized(){};
virtual ~vpMomentAreaNormalized() { };
void compute();
/*!
Retrieves the desired surface \e a* as specified in the constructor.
Expand All @@ -153,11 +153,7 @@ class VISP_EXPORT vpMomentAreaNormalized : public vpMoment
Retrieves the desired depth \e Z* as specified in the constructor.
*/
double getDesiredDepth() const { return desiredDepth; }
/*!
\deprecated Use rather getDesiredArea()
Retrieves the desired surface \e a* as specified in the constructor.
*/
vp_deprecated double getDesiredSurface() const { return desiredSurface; }

/*!
Set the desired depth \e Z* to a new value than the one specified in the constructor.
This value has to be set before calling compute().
Expand All @@ -169,6 +165,20 @@ class VISP_EXPORT vpMomentAreaNormalized : public vpMoment
*/
void setDesiredArea(double a_star) { desiredSurface = a_star; }


#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
/*!
@name Deprecated functions
*/
//@{
/*!
\deprecated Use rather getDesiredArea()
Retrieves the desired surface \e a* as specified in the constructor.
*/
vp_deprecated double getDesiredSurface() const { return desiredSurface; }
//@}
#endif

/*!
Moment name.
*/
Expand Down
3 changes: 2 additions & 1 deletion modules/core/include/visp3/core/vpRowVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class VISP_EXPORT vpRowVector : public vpArray2D<double>
(*this) *= d2r;
}

vp_deprecated double euclideanNorm() const;

/*!
Extract a sub-row vector from a row vector.
\param c : Index of the column corresponding to the first element of the
Expand Down Expand Up @@ -335,6 +335,7 @@ class VISP_EXPORT vpRowVector : public vpArray2D<double>
\deprecated You should rather use eye()
*/
vp_deprecated void setIdentity(const double &val = 1.0);
vp_deprecated double euclideanNorm() const;
//@}
#endif
};
Expand Down
12 changes: 10 additions & 2 deletions modules/core/include/visp3/core/vpTranslationVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class VISP_EXPORT vpTranslationVector : public vpArray2D<double>
Default constructor.
The translation vector is initialized to zero.
*/
vpTranslationVector() : vpArray2D<double>(3, 1), m_index(0){};
vpTranslationVector() : vpArray2D<double>(3, 1), m_index(0) { };
vpTranslationVector(double tx, double ty, double tz);
vpTranslationVector(const vpTranslationVector &tv);
explicit vpTranslationVector(const vpHomogeneousMatrix &M);
Expand All @@ -131,7 +131,6 @@ class VISP_EXPORT vpTranslationVector : public vpArray2D<double>
vpTranslationVector buildFrom(const vpPoseVector &p);
vpTranslationVector buildFrom(const vpColVector &v);

vp_deprecated double euclideanNorm() const;
double frobeniusNorm() const;

// operators
Expand Down Expand Up @@ -193,6 +192,15 @@ class VISP_EXPORT vpTranslationVector : public vpArray2D<double>
static vpMatrix skew(const vpTranslationVector &tv);
static void skew(const vpTranslationVector &tv, vpMatrix &M);

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
/*!
@name Deprecated functions
*/
//@{
vp_deprecated double euclideanNorm() const;
//}
#endif

protected:
unsigned int m_index; // index used for operator<< and operator, to fill a vector
};
Expand Down
23 changes: 13 additions & 10 deletions modules/core/src/math/matrix/vpColVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1489,17 +1489,7 @@ double vpColVector::sum() const { return SimdVectorSum(data, rowNum); }
*/
double vpColVector::sumSquare() const { return SimdVectorSumSquare(data, rowNum); }

/*!
\deprecated This function is deprecated. You should rather use frobeniusNorm().
Compute and return the Euclidean norm also called Fronebius norm \f$ ||v|| = \sqrt{ \sum{v_{i}^2}} \f$.
\return The Euclidean norm if the vector is initialized, 0 otherwise.

\sa frobeniusNorm(), infinityNorm()
*/
double vpColVector::euclideanNorm() const { return frobeniusNorm(); }

/*!
Compute and return the Fronebius norm \f$ ||v|| = \sqrt{ \sum{v_{i}^2}} \f$.
Expand Down Expand Up @@ -1732,6 +1722,7 @@ std::ostream &vpColVector::matlabPrint(std::ostream &os) const
};

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)

/*!
\deprecated You should rather use insert(unsigned int, const vpColVector &).
Expand All @@ -1751,4 +1742,16 @@ void vpColVector::insert(const vpColVector &v, unsigned int r, unsigned int c)
(void)c;
insert(r, v);
}

/*!
\deprecated This function is deprecated. You should rather use frobeniusNorm().
Compute and return the Euclidean norm also called Fronebius norm \f$ ||v|| = \sqrt{ \sum{v_{i}^2}} \f$.
\return The Euclidean norm if the vector is initialized, 0 otherwise.
\sa frobeniusNorm(), infinityNorm()
*/
double vpColVector::euclideanNorm() const { return frobeniusNorm(); }
#endif // defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
41 changes: 24 additions & 17 deletions modules/core/src/math/matrix/vpRowVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ vpRowVector &vpRowVector::operator=(const vpRowVector &v)
if (colNum != k) {
try {
resize(k);
} catch (...) {
}
catch (...) {
throw;
}
}
Expand Down Expand Up @@ -699,7 +700,8 @@ void vpRowVector::reshape(vpMatrix &M, const unsigned int &nrows, const unsigned
try {
if ((M.getRows() != nrows) || (M.getCols() != ncols))
M.resize(nrows, ncols);
} catch (...) {
}
catch (...) {
throw;
}
for (unsigned int i = 0; i < nrows; i++)
Expand Down Expand Up @@ -989,7 +991,8 @@ int vpRowVector::print(std::ostream &s, unsigned int length, char const *intro)
if (p == std::string::npos) {
maxBefore = vpMath::maximum(maxBefore, thislen);
// maxAfter remains the same
} else {
}
else {
maxBefore = vpMath::maximum(maxBefore, p);
maxAfter = vpMath::maximum(maxAfter, thislen - p - 1);
}
Expand Down Expand Up @@ -1022,7 +1025,8 @@ int vpRowVector::print(std::ostream &s, unsigned int length, char const *intro)
if (p != std::string::npos) {
s.width((std::streamsize)maxAfter);
s << values[j].substr(p, maxAfter).c_str();
} else {
}
else {
assert(maxAfter > 1);
s.width((std::streamsize)maxAfter);
s << ".0";
Expand Down Expand Up @@ -1082,17 +1086,6 @@ double vpRowVector::sumSquare() const
return sum_square;
}

/*!
\deprecated This function is deprecated. You should rather use frobeniusNorm().
Compute and return the Euclidean norm also called Fronebius norm \f$ ||v|| = \sqrt{ \sum{v_{i}^2}} \f$.
\return The Euclidean norm if the vector is initialized, 0 otherwise.
\sa frobeniusNorm()
*/
double vpRowVector::euclideanNorm() const { return frobeniusNorm(); }

/*!
Compute and return the Fronebius norm \f$ ||v|| = \sqrt{ \sum{v_{i}^2}} \f$.
Expand All @@ -1105,6 +1098,19 @@ double vpRowVector::frobeniusNorm() const
return sqrt(norm);
}

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
/*!
\deprecated This function is deprecated. You should rather use frobeniusNorm().
Compute and return the Euclidean norm also called Fronebius norm \f$ ||v|| = \sqrt{ \sum{v_{i}^2}} \f$.
\return The Euclidean norm if the vector is initialized, 0 otherwise.
\sa frobeniusNorm()
*/
double vpRowVector::euclideanNorm() const { return frobeniusNorm(); }
#endif

/*!
Initialize the row vector from a part of an input row vector \e v.
Expand Down Expand Up @@ -1191,10 +1197,11 @@ std::ostream &vpRowVector::cppPrint(std::ostream &os, const std::string &matrixN
for (unsigned int j = 0; j < this->getCols(); ++j) {
if (!octet) {
os << matrixName << "[" << j << "] = " << (*this)[j] << "; " << std::endl;
} else {
}
else {
for (unsigned int k = 0; k < sizeof(double); ++k) {
os << "((unsigned char*)&(" << matrixName << "[" << j << "]) )[" << k << "] = 0x" << std::hex
<< (unsigned int)((unsigned char *)&((*this)[j]))[k] << "; " << std::endl;
<< (unsigned int)((unsigned char *)&((*this)[j]))[k] << "; " << std::endl;
}
}
}
Expand Down
24 changes: 15 additions & 9 deletions modules/core/src/math/transformation/vpTranslationVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ vpTranslationVector::vpTranslationVector(const vpPoseVector &p) : vpArray2D<doub
vpTranslationVector t2(t1); // t2 is now a copy of t1
\endcode
*/
vpTranslationVector::vpTranslationVector(const vpTranslationVector &tv) : vpArray2D<double>(tv), m_index(0) {}
vpTranslationVector::vpTranslationVector(const vpTranslationVector &tv) : vpArray2D<double>(tv), m_index(0) { }

/*!
Construct a translation vector \f$ \bf t \f$ from a 3-dimension column
Expand Down Expand Up @@ -445,7 +445,8 @@ vpTranslationVector &vpTranslationVector::operator=(const vpColVector &tv)
if (rowNum != k) {
try {
resize(k, 1);
} catch (...) {
}
catch (...) {
throw;
}
}
Expand Down Expand Up @@ -473,7 +474,8 @@ vpTranslationVector &vpTranslationVector::operator=(const vpTranslationVector &t
if (rowNum != k) {
try {
resize(k, 1);
} catch (...) {
}
catch (...) {
throw;
}
}
Expand Down Expand Up @@ -526,9 +528,9 @@ vpTranslationVector &vpTranslationVector::operator=(const std::initializer_list<
{
if (list.size() > size()) {
throw(vpException(
vpException::dimensionError,
"Cannot set translation vector out of bounds. It has only %d values while you try to initialize with %d values",
size(), list.size()));
vpException::dimensionError,
"Cannot set translation vector out of bounds. It has only %d values while you try to initialize with %d values",
size(), list.size()));
}
std::copy(list.begin(), list.end(), data);
return *this;
Expand Down Expand Up @@ -593,9 +595,9 @@ vpTranslationVector &vpTranslationVector::operator,(double val)
m_index++;
if (m_index >= size()) {
throw(vpException(
vpException::dimensionError,
"Cannot set translation vector out of bounds. It has only %d values while you try to initialize with %d values",
size(), m_index + 1));
vpException::dimensionError,
"Cannot set translation vector out of bounds. It has only %d values while you try to initialize with %d values",
size(), m_index + 1));
}
data[m_index] = val;
return *this;
Expand Down Expand Up @@ -707,6 +709,8 @@ vpRowVector vpTranslationVector::t() const
return v;
}

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)

/*!
\deprecated This function is deprecated. You should rather use frobeniusNorm().
Expand All @@ -719,6 +723,8 @@ vpRowVector vpTranslationVector::t() const
*/
double vpTranslationVector::euclideanNorm() const { return frobeniusNorm(); }

#endif

/*!
Compute and return the Fronebius norm \f$ ||t|| = \sqrt{ \sum{t_{i}^2}} \f$.
Expand Down

0 comments on commit 6c9a74e

Please sign in to comment.