Skip to content

Commit

Permalink
Remove boost ptr and use STL
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Romain committed Aug 18, 2020
1 parent ff3ca61 commit b6d990a
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/Algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

#include <cmath>
#include <iostream>
#include <memory>

#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/shared_ptr.hpp>

#include "Algorithm.h"
#include "DuplicatePoints.h"
Expand Down Expand Up @@ -105,7 +105,7 @@ namespace mcc
break;
}
//std::cout << "SD " << SD << " - Pass " << pass << std::endl << indent << "Interpolating " << U.count() << " points:" << std::endl;
boost::shared_ptr<IRasterSurface> rasterSurface = surfaceInterpolation_(U, CR[SD], tension);
std::shared_ptr<IRasterSurface> rasterSurface = surfaceInterpolation_(U, CR[SD], tension);

//std::cout << indent << "Averaging raster surface..." << std::endl;
rasterSurface->average(3); // kernel = 3x3
Expand Down
2 changes: 1 addition & 1 deletion src/DisjointRegions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ namespace mcc
double regionWidth = rasterWidth / nColumns;

// Create the 2-d arry of InterpolationRegion (nRows, nColumns)
regions_ = boost::make_shared< Grid<InterpolationRegion> >(nRows, nColumns, raster.lowerLeft(),
regions_ = std::make_shared< Grid<InterpolationRegion> >(nRows, nColumns, raster.lowerLeft(),
Coordinate(regionHeight),
Coordinate(regionWidth));

Expand Down
4 changes: 2 additions & 2 deletions src/DisjointRegions.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef MCC_DISJOINT_REGIONS_H
#define MCC_DISJOINT_REGIONS_H

#include <boost/shared_ptr.hpp>
#include <memory>

#include "Grid.h"
#include "InterpolationRegion.h"
Expand All @@ -42,7 +42,7 @@ namespace mcc
void addNeighborPointsToCurrentRegion(int nPoints);

private:
boost::shared_ptr< Grid<InterpolationRegion> > regions_;
std::shared_ptr< Grid<InterpolationRegion> > regions_;
const RasterSurface * raster_;
enum { RegionIteration_Initialized,
RegionIteration_InProgress,
Expand Down
7 changes: 4 additions & 3 deletions src/IDataFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
#ifndef MCC_IDATA_FORMAT_H
#define MCC_IDATA_FORMAT_H

#include <memory>

#include <boost/filesystem.hpp>
#include <boost/shared_ptr.hpp>

#include "IXyzPointReader.h"
#include "IClassificationVector.h"
Expand All @@ -28,7 +29,7 @@ namespace mcc
{
public:
// Opens a data file for reading.
virtual boost::shared_ptr<IXyzPointReader> openFile(const boost::filesystem::path & path) = 0;
virtual std::shared_ptr<IXyzPointReader> openFile(const boost::filesystem::path & path) = 0;

// Copies point data from one file to another, and sets the classification
// for the points in the new file.
Expand All @@ -37,7 +38,7 @@ namespace mcc
double scaleDomain2Spacing,
double curvatureThreshold,
const IClassificationVector & ptClassifications) = 0;

virtual ~IDataFormat() { }
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/ISurfaceInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef MCC_ISURFACE_INTERPOLATION_H
#define MCC_ISURFACE_INTERPOLATION_H

#include <boost/shared_ptr.hpp>
#include <memory>

namespace mcc
{
Expand All @@ -25,7 +25,7 @@ namespace mcc
class ISurfaceInterpolation
{
public:
virtual boost::shared_ptr<IRasterSurface> operator()(const IPointVector & points,
virtual std::shared_ptr<IRasterSurface> operator()(const IPointVector & points,
double cellResolution,
double tension) = 0;
virtual ~ISurfaceInterpolation() { }
Expand Down
8 changes: 4 additions & 4 deletions src/PointVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace mcc
IPointVector::const_iterator PointVector::begin() const
{
#ifdef _MSC_VER
IPointVector::const_iterator itor( boost::make_shared<VectorOfPoints::const_iterator>(points_.begin()) );
IPointVector::const_iterator itor( std::make_shared<VectorOfPoints::const_iterator>(points_.begin()) );
#else
IPointVector::const_iterator itor;
itor = points_.begin();
Expand All @@ -72,7 +72,7 @@ namespace mcc
IPointVector::const_iterator PointVector::end() const
{
#ifdef _MSC_VER
IPointVector::const_iterator itor( boost::make_shared<VectorOfPoints::const_iterator>(points_.end()) );
IPointVector::const_iterator itor( std::make_shared<VectorOfPoints::const_iterator>(points_.end()) );
#else
IPointVector::const_iterator itor;
itor = points_.end();
Expand All @@ -85,7 +85,7 @@ namespace mcc
IPointVector::iterator PointVector::begin()
{
#ifdef _MSC_VER
IPointVector::iterator itor( boost::make_shared<VectorOfPoints::iterator>(points_.begin()) );
IPointVector::iterator itor( std::make_shared<VectorOfPoints::iterator>(points_.begin()) );
#else
IPointVector::iterator itor;
itor = points_.begin();
Expand All @@ -98,7 +98,7 @@ namespace mcc
IPointVector::iterator PointVector::end()
{
#ifdef _MSC_VER
IPointVector::iterator itor( boost::make_shared<VectorOfPoints::iterator>(points_.end()) );
IPointVector::iterator itor( std::make_shared<VectorOfPoints::iterator>(points_.end()) );
#else
IPointVector::iterator itor;
itor = points_.end();
Expand Down
5 changes: 2 additions & 3 deletions src/R_MCC.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Rcpp.h>
#include <boost/shared_ptr.hpp>
#include <memory>

#include "Algorithm.h"
#include "PointVector.h"
Expand All @@ -11,7 +11,6 @@

using namespace Rcpp;
using namespace mcc;
using boost::shared_ptr;

// [[Rcpp::export]]
IntegerVector R_MCC(DataFrame data, double scaleDomain2Spacing = 1.5, double curvatureThreshold = 0.3)
Expand All @@ -26,7 +25,7 @@ IntegerVector R_MCC(DataFrame data, double scaleDomain2Spacing = 1.5, double cur
NumericVector Z = data[z];
int n = X.size();

shared_ptr<PointVector> points(new PointVector(n));
std::shared_ptr<PointVector> points(new PointVector(n));

for (int i = 0 ; i < n ; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/RegularizedSpline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mcc::RegularizedSpline::RegularizedSpline(const std::vector<const IPoint *> & po
i++;
}
try {
spline_ = boost::shared_ptr<tpsdemo::Spline>(new tpsdemo::Spline(controlPoints_, regularization));
spline_ = std::shared_ptr<tpsdemo::Spline>(new tpsdemo::Spline(controlPoints_, regularization));
}
catch (tpsdemo::SingularMatrixError) {
throw SingularMatrixException(points);
Expand Down
4 changes: 2 additions & 2 deletions src/RegularizedSpline.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define MCC_REGULARIZED_SPLINE_H

#include <vector>
#include <boost/shared_ptr.hpp>
#include <memory>

#include "Coordinate.h"
#include "IPoint.h"
Expand All @@ -40,7 +40,7 @@ namespace mcc

private:
std::vector<Vec> controlPoints_;
boost::shared_ptr<tpsdemo::Spline> spline_;
std::shared_ptr<tpsdemo::Spline> spline_;
};
}

Expand Down
11 changes: 5 additions & 6 deletions src/SurfaceInterpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

#include <cmath>
#include <iostream>
#include <memory>

#include <boost/foreach.hpp>
#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>

#include "DisjointRegions.h"
#include "IInterpolationRegion.h"
Expand Down Expand Up @@ -49,7 +48,7 @@ namespace mcc

//---------------------------------------------------------------------------

boost::shared_ptr<IRasterSurface> SurfaceInterpolation::operator()(const IPointVector & points,
std::shared_ptr<IRasterSurface> SurfaceInterpolation::operator()(const IPointVector & points,
double cellResolution,
double tension)
{
Expand All @@ -58,7 +57,7 @@ namespace mcc

//---------------------------------------------------------------------------

boost::shared_ptr<IRasterSurface> SurfaceInterpolation::operator()(const IPointVector & points,
std::shared_ptr<IRasterSurface> SurfaceInterpolation::operator()(const IPointVector & points,
PointSelector pointSelector,
double cellResolution,
double tension)
Expand Down Expand Up @@ -89,14 +88,14 @@ namespace mcc

XYCoordinates lowerLeft(x0, y0);

rasterSurface_ = boost::make_shared<RasterSurface>(rows, cols, lowerLeft, Coordinate(cellResolution));
rasterSurface_ = std::make_shared<RasterSurface>(rows, cols, lowerLeft, Coordinate(cellResolution));
prevCellResolution_ = cellResolution;
}


// Determine where splines will be interpolated for the points and the
// raster.
boost::shared_ptr<IRegionGenerator> regions = boost::make_shared<DisjointRegions>();
std::shared_ptr<IRegionGenerator> regions = std::make_shared<DisjointRegions>();
int nRegions = regions->subdivide(points, pointSelector, *rasterSurface_);

rasterSurface_->setNoDataValue(-9999);
Expand Down
8 changes: 4 additions & 4 deletions src/SurfaceInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef MCC_SURFACE_INTERPOLATION_H
#define MCC_SURFACE_INTERPOLATION_H

#include <boost/shared_ptr.hpp>
#include <memory>

#include "ISurfaceInterpolation.h"
#include "PointSelector.h"
Expand All @@ -36,21 +36,21 @@ namespace mcc
void setXyExtent(const XyExtent & xyExtent);

// ISurfaceInterpolation interface
boost::shared_ptr<IRasterSurface> operator()(const IPointVector & points,
std::shared_ptr<IRasterSurface> operator()(const IPointVector & points,
double cellResolution,
double tension);

// Interpolate a raster surface from a selected group of points within a
// point vector.
boost::shared_ptr<IRasterSurface> operator()(const IPointVector & points,
std::shared_ptr<IRasterSurface> operator()(const IPointVector & points,
PointSelector pointSelector,
double cellResolution,
double tension);

private:
XyExtent inputExtent_;
double prevCellResolution_;
boost::shared_ptr<RasterSurface> rasterSurface_;
std::shared_ptr<RasterSurface> rasterSurface_;
};

//---------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions src/UnclassifiedPoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace mcc

//-------------------------------------------------------------------------

UnclassifiedPoints::UnclassifiedPoints(boost::shared_ptr<PointVector> points)
UnclassifiedPoints::UnclassifiedPoints(std::shared_ptr<PointVector> points)
: points_(points), unclassifiedPoints_(points->count())
{
PointVector & pts = *points_;
Expand All @@ -67,7 +67,7 @@ namespace mcc
IPointVector::const_iterator UnclassifiedPoints::begin() const
{
#ifdef _MSC_VER
IPointVector::const_iterator itor( boost::make_shared<VectorOfPointers::const_iterator>(unclassifiedPoints_.begin()) );
IPointVector::const_iterator itor( std::make_shared<VectorOfPointers::const_iterator>(unclassifiedPoints_.begin()) );
#else
IPointVector::const_iterator itor;
itor = boost::make_indirect_iterator(unclassifiedPoints_.begin());
Expand All @@ -80,7 +80,7 @@ namespace mcc
IPointVector::const_iterator UnclassifiedPoints::end() const
{
#ifdef _MSC_VER
IPointVector::const_iterator itor( boost::make_shared<VectorOfPointers::const_iterator>(unclassifiedPoints_.end()) );
IPointVector::const_iterator itor( std::make_shared<VectorOfPointers::const_iterator>(unclassifiedPoints_.end()) );
#else
IPointVector::const_iterator itor;
itor = boost::make_indirect_iterator(unclassifiedPoints_.end());
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace mcc
IPointVector::iterator UnclassifiedPoints::begin()
{
#ifdef _MSC_VER
IPointVector::iterator itor( boost::make_shared<VectorOfPointers::iterator>(unclassifiedPoints_.begin()) );
IPointVector::iterator itor( std::make_shared<VectorOfPointers::iterator>(unclassifiedPoints_.begin()) );
#else
IPointVector::iterator itor;
itor = boost::make_indirect_iterator(unclassifiedPoints_.begin());
Expand All @@ -126,7 +126,7 @@ namespace mcc
IPointVector::iterator UnclassifiedPoints::end()
{
#ifdef _MSC_VER
IPointVector::iterator itor( boost::make_shared<VectorOfPointers::iterator>(unclassifiedPoints_.end()) );
IPointVector::iterator itor( std::make_shared<VectorOfPointers::iterator>(unclassifiedPoints_.end()) );
#else
IPointVector::iterator itor;
itor = boost::make_indirect_iterator(unclassifiedPoints_.end());
Expand Down
6 changes: 3 additions & 3 deletions src/UnclassifiedPoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define MCC_UNCLASSIFIED_POINTS_H

#include <vector>
#include <boost/shared_ptr.hpp>
#include <memory>
#include "IUnclassifiedPoints.h"

namespace mcc
Expand All @@ -31,7 +31,7 @@ namespace mcc
using IPointVector::size_type;

// Create an instance that references an existing point vector.
UnclassifiedPoints(boost::shared_ptr<PointVector> points);
UnclassifiedPoints(std::shared_ptr<PointVector> points);

// IUnclassifiedPoints interface
IPointVector::size_type removeClassified();
Expand All @@ -44,7 +44,7 @@ namespace mcc
IPointVector::const_iterator end() const;

private:
boost::shared_ptr<PointVector> points_;
std::shared_ptr<PointVector> points_;
std::vector<Point *> unclassifiedPoints_;

void findUnclassifiedPoints();
Expand Down
7 changes: 3 additions & 4 deletions src/VectorWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define MCC_VECTOR_ITERATORS_H

#include <vector>
#include <boost/make_shared.hpp>
#include "PointVectorIteratorImpl.h"
#include "IPoint.h"

Expand Down Expand Up @@ -44,14 +43,14 @@ namespace mcc
{
}

boost::shared_ptr< PointVectorIteratorImpl<TPoint> > clone() const
std::shared_ptr< PointVectorIteratorImpl<TPoint> > clone() const
{
return boost::make_shared< IteratorWrapper<TPoint, TVectorIterator> >(itor_);
return std::make_shared< IteratorWrapper<TPoint, TVectorIterator> >(itor_);
}

TPoint & operator*() const
{
return dereference<TPoint, TVectorIterator>(itor_);
return dereference<TPoint, TVectorIterator>(itor_);
}

PointVectorIteratorImpl<TPoint> & operator++()
Expand Down

0 comments on commit b6d990a

Please sign in to comment.