modernize C++: make unique

This commit is contained in:
wmayer
2023-08-07 20:01:45 +02:00
committed by Chris Hennes
parent c2e17824fa
commit ec73caa40e
30 changed files with 134 additions and 124 deletions

View File

@@ -257,14 +257,14 @@ private:
meta[App::Application::Config()["ExeName"] + "-buildRevisionHash"] =
App::Application::Config()["BuildRevisionHash"];
exporter.reset( new ExporterAMF(outputFileName, meta, exportAmfCompressed) );
exporter = std::make_unique<ExporterAMF>(outputFileName, meta, exportAmfCompressed);
}
else if (exportFormat == MeshIO::ThreeMF) {
Extension3MFFactory::initialize();
exporter.reset( new Exporter3MF(outputFileName, Extension3MFFactory::createExtensions()) );
exporter = std::make_unique<Exporter3MF>(outputFileName, Extension3MFFactory::createExtensions());
}
else if (exportFormat != MeshIO::Undefined) {
exporter.reset( new MergeExporter(outputFileName, exportFormat) );
exporter = std::make_unique<MergeExporter>(outputFileName, exportFormat);
}
else {
std::string exStr("Can't determine mesh format from file name.\nPlease specify mesh format file extension: '");

View File

@@ -280,7 +280,7 @@ public:
Exporter3MF::Exporter3MF(std::string fileName, const std::vector<Extension3MFPtr>& ext)
{
throwIfNoPermission(fileName);
d.reset(new Private(fileName, ext));
d = std::make_unique<Private>(fileName, ext);
}
Exporter3MF::~Exporter3MF()

View File

@@ -119,7 +119,7 @@ Data::Segment* MeshObject::getSubElement(const char* Type, unsigned long n) cons
MeshSegment* segm = new MeshSegment();
segm->mesh = new MeshObject(*this);
const Segment& faces = getSegment(n);
segm->segment.reset(new Segment(static_cast<MeshObject*>(segm->mesh), faces.getIndices(), false));
segm->segment = std::make_unique<Segment>(static_cast<MeshObject*>(segm->mesh), faces.getIndices(), false);
return segm;
}

View File

@@ -267,7 +267,7 @@ PyObject* MeshPy::write(PyObject *args, PyObject *kwds)
std::unique_ptr<MeshCore::Material> mat;
if (List) {
mat.reset(new MeshCore::Material);
mat = std::make_unique<MeshCore::Material>();
Py::Sequence list(List);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
Py::Tuple t(*it);

View File

@@ -35,12 +35,12 @@ MeshTexture::MeshTexture(const Mesh::MeshObject& mesh, const MeshCore::Material
if (material.binding == MeshCore::MeshIO::PER_VERTEX && material.diffuseColor.size() == countPointsRefMesh) {
binding = MeshCore::MeshIO::PER_VERTEX;
kdTree.reset(new MeshCore::MeshKDTree(mesh.getKernel().GetPoints()));
kdTree = std::make_unique<MeshCore::MeshKDTree>(mesh.getKernel().GetPoints());
}
else if (material.binding == MeshCore::MeshIO::PER_FACE && material.diffuseColor.size() == countFacets) {
binding = MeshCore::MeshIO::PER_FACE;
kdTree.reset(new MeshCore::MeshKDTree(mesh.getKernel().GetPoints()));
refPnt2Fac.reset(new MeshCore::MeshRefPointToFacets(mesh.getKernel()));
kdTree = std::make_unique<MeshCore::MeshKDTree>(mesh.getKernel().GetPoints());
refPnt2Fac = std::make_unique<MeshCore::MeshRefPointToFacets>(mesh.getKernel());
}
}

View File

@@ -1043,12 +1043,12 @@ PyObject* BSplineCurvePy::interpolate(PyObject *args, PyObject *kwds)
std::unique_ptr<GeomAPI_Interpolate> aBSplineInterpolation;
if (parameters.IsNull()) {
aBSplineInterpolation.reset(new GeomAPI_Interpolate(interpolationPoints,
Base::asBoolean(periodic), tol3d));
aBSplineInterpolation = std::make_unique<GeomAPI_Interpolate>(interpolationPoints,
Base::asBoolean(periodic), tol3d);
}
else {
aBSplineInterpolation.reset(new GeomAPI_Interpolate(interpolationPoints, parameters,
Base::asBoolean(periodic), tol3d));
aBSplineInterpolation = std::make_unique<GeomAPI_Interpolate>(interpolationPoints, parameters,
Base::asBoolean(periodic), tol3d);
}
if (t1 && t2) {

View File

@@ -121,8 +121,8 @@ void FaceMakerBullseye::Build_Essence()
}
else {
//wire is not on a face. Start a new face.
faces.push_back(std::unique_ptr<FaceDriller>(
new FaceDriller(plane, w)
faces.push_back(std::make_unique<FaceDriller>(
plane, w
));
}
}

View File

@@ -949,12 +949,16 @@ PyObject* BSplineCurve2dPy::interpolate(PyObject *args, PyObject *kwds)
std::unique_ptr<Geom2dAPI_Interpolate> aBSplineInterpolation;
if (parameters.IsNull()) {
aBSplineInterpolation.reset(new Geom2dAPI_Interpolate(interpolationPoints,
Base::asBoolean(periodic), tol3d));
aBSplineInterpolation = std::make_unique<Geom2dAPI_Interpolate>(
interpolationPoints,
Base::asBoolean(periodic), tol3d
);
}
else {
aBSplineInterpolation.reset(new Geom2dAPI_Interpolate(interpolationPoints, parameters,
Base::asBoolean(periodic), tol3d));
aBSplineInterpolation = std::make_unique<Geom2dAPI_Interpolate>(
interpolationPoints, parameters,
Base::asBoolean(periodic), tol3d
);
}
if (t1 && t2) {

View File

@@ -99,10 +99,10 @@ int CurveConstraintPy::PyInit(PyObject* args, PyObject* kwds)
}
#endif
ptr.reset(new GeomPlate_CurveConstraint(hCurve, order, nbPts, tolDist, tolAng, tolCurv));
ptr = std::make_unique<GeomPlate_CurveConstraint>(hCurve, order, nbPts, tolDist, tolAng, tolCurv);
}
else {
ptr.reset(new GeomPlate_CurveConstraint);
ptr = std::make_unique<GeomPlate_CurveConstraint>();
}
setTwinPointer(ptr.release());

View File

@@ -56,7 +56,7 @@ int PointConstraintPy::PyInit(PyObject* args, PyObject* kwds)
std::unique_ptr<GeomPlate_PointConstraint> ptr;
Base::Vector3d v = static_cast<Base::VectorPy*>(pt)->value();
ptr.reset(new GeomPlate_PointConstraint(gp_Pnt(v.x, v.y, v.z), order, tolDist));
ptr = std::make_unique<GeomPlate_PointConstraint>(gp_Pnt(v.x, v.y, v.z), order, tolDist);
setTwinPointer(ptr.release());
return 0;

View File

@@ -5365,51 +5365,51 @@ std::unique_ptr<GeomSurface> makeFromSurface(const Handle(Geom_Surface)& s)
std::unique_ptr<GeomSurface> geoSurf;
if (s->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) {
Handle(Geom_ToroidalSurface) hSurf = Handle(Geom_ToroidalSurface)::DownCast(s);
geoSurf.reset(new GeomToroid(hSurf));
geoSurf = std::make_unique<GeomToroid>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(Geom_BezierSurface))) {
Handle(Geom_BezierSurface) hSurf = Handle(Geom_BezierSurface)::DownCast(s);
geoSurf.reset(new GeomBezierSurface(hSurf));
geoSurf = std::make_unique<GeomBezierSurface>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) {
Handle(Geom_BSplineSurface) hSurf = Handle(Geom_BSplineSurface)::DownCast(s);
geoSurf.reset(new GeomBSplineSurface(hSurf));
geoSurf = std::make_unique<GeomBSplineSurface>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
Handle(Geom_CylindricalSurface) hSurf = Handle(Geom_CylindricalSurface)::DownCast(s);
geoSurf.reset(new GeomCylinder(hSurf));
geoSurf = std::make_unique<GeomCylinder>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
Handle(Geom_ConicalSurface) hSurf = Handle(Geom_ConicalSurface)::DownCast(s);
geoSurf.reset(new GeomCone(hSurf));
geoSurf = std::make_unique<GeomCone>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
Handle(Geom_SphericalSurface) hSurf = Handle(Geom_SphericalSurface)::DownCast(s);
geoSurf.reset(new GeomSphere(hSurf));
geoSurf = std::make_unique<GeomSphere>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(Geom_Plane))) {
Handle(Geom_Plane) hSurf = Handle(Geom_Plane)::DownCast(s);
geoSurf.reset(new GeomPlane(hSurf));
geoSurf = std::make_unique<GeomPlane>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
Handle(Geom_OffsetSurface) hSurf = Handle(Geom_OffsetSurface)::DownCast(s);
geoSurf.reset(new GeomOffsetSurface(hSurf));
geoSurf = std::make_unique<GeomOffsetSurface>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(GeomPlate_Surface))) {
Handle(GeomPlate_Surface) hSurf = Handle(GeomPlate_Surface)::DownCast(s);
geoSurf.reset(new GeomPlateSurface(hSurf));
geoSurf = std::make_unique<GeomPlateSurface>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
Handle(Geom_RectangularTrimmedSurface) hSurf = Handle(Geom_RectangularTrimmedSurface)::DownCast(s);
geoSurf.reset(new GeomTrimmedSurface(hSurf));
geoSurf = std::make_unique<GeomTrimmedSurface>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
Handle(Geom_SurfaceOfRevolution) hSurf = Handle(Geom_SurfaceOfRevolution)::DownCast(s);
geoSurf.reset(new GeomSurfaceOfRevolution(hSurf));
geoSurf = std::make_unique<GeomSurfaceOfRevolution>(hSurf);
}
else if (s->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) {
Handle(Geom_SurfaceOfLinearExtrusion) hSurf = Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(s);
geoSurf.reset(new GeomSurfaceOfExtrusion(hSurf));
geoSurf = std::make_unique<GeomSurfaceOfExtrusion>(hSurf);
}
else {
std::string err = "Unhandled surface type ";
@@ -5425,27 +5425,27 @@ std::unique_ptr<GeomCurve> makeFromCurve(const Handle(Geom_Curve)& c)
std::unique_ptr<GeomCurve> geoCurve;
if (c->IsKind(STANDARD_TYPE(Geom_Circle))) {
Handle(Geom_Circle) circ = Handle(Geom_Circle)::DownCast(c);
geoCurve.reset(new GeomCircle(circ));
geoCurve = std::make_unique<GeomCircle>(circ);
}
else if (c->IsKind(STANDARD_TYPE(Geom_Ellipse))) {
Handle(Geom_Ellipse) ell = Handle(Geom_Ellipse)::DownCast(c);
geoCurve.reset(new GeomEllipse(ell));
geoCurve = std::make_unique<GeomEllipse>(ell);
}
else if (c->IsKind(STANDARD_TYPE(Geom_Hyperbola))) {
Handle(Geom_Hyperbola) hyp = Handle(Geom_Hyperbola)::DownCast(c);
geoCurve.reset(new GeomHyperbola(hyp));
geoCurve = std::make_unique<GeomHyperbola>(hyp);
}
else if (c->IsKind(STANDARD_TYPE(Geom_Line))) {
Handle(Geom_Line) lin = Handle(Geom_Line)::DownCast(c);
geoCurve.reset(new GeomLine(lin));
geoCurve = std::make_unique<GeomLine>(lin);
}
else if (c->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) {
Handle(Geom_OffsetCurve) oc = Handle(Geom_OffsetCurve)::DownCast(c);
geoCurve.reset(new GeomOffsetCurve(oc));
geoCurve = std::make_unique<GeomOffsetCurve>(oc);
}
else if (c->IsKind(STANDARD_TYPE(Geom_Parabola))) {
Handle(Geom_Parabola) par = Handle(Geom_Parabola)::DownCast(c);
geoCurve.reset(new GeomParabola(par));
geoCurve = std::make_unique<GeomParabola>(par);
}
else if (c->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
return makeFromTrimmedCurve(c, c->FirstParameter(), c->LastParameter());
@@ -5456,11 +5456,11 @@ std::unique_ptr<GeomCurve> makeFromCurve(const Handle(Geom_Curve)& c)
}*/
else if (c->IsKind(STANDARD_TYPE(Geom_BezierCurve))) {
Handle(Geom_BezierCurve) bezier = Handle(Geom_BezierCurve)::DownCast(c);
geoCurve.reset(new GeomBezierCurve(bezier));
geoCurve = std::make_unique<GeomBezierCurve>(bezier);
}
else if (c->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
Handle(Geom_BSplineCurve) bspline = Handle(Geom_BSplineCurve)::DownCast(c);
geoCurve.reset(new GeomBSplineCurve(bspline));
geoCurve = std::make_unique<GeomBSplineCurve>(bspline);
}
else {
std::string err = "Unhandled curve type ";
@@ -5567,7 +5567,7 @@ std::unique_ptr<GeomCurve> makeFromCurveAdaptor(const Adaptor3d_Curve& adapt)
{
case GeomAbs_Line:
{
geoCurve.reset(new GeomLine());
geoCurve = std::make_unique<GeomLine>();
Handle(Geom_Line) this_curv = Handle(Geom_Line)::DownCast
(geoCurve->handle());
this_curv->SetLin(adapt.Line());
@@ -5575,7 +5575,7 @@ std::unique_ptr<GeomCurve> makeFromCurveAdaptor(const Adaptor3d_Curve& adapt)
}
case GeomAbs_Circle:
{
geoCurve.reset(new GeomCircle());
geoCurve = std::make_unique<GeomCircle>();
Handle(Geom_Circle) this_curv = Handle(Geom_Circle)::DownCast
(geoCurve->handle());
this_curv->SetCirc(adapt.Circle());
@@ -5583,7 +5583,7 @@ std::unique_ptr<GeomCurve> makeFromCurveAdaptor(const Adaptor3d_Curve& adapt)
}
case GeomAbs_Ellipse:
{
geoCurve.reset(new GeomEllipse());
geoCurve = std::make_unique<GeomEllipse>();
Handle(Geom_Ellipse) this_curv = Handle(Geom_Ellipse)::DownCast
(geoCurve->handle());
this_curv->SetElips(adapt.Ellipse());
@@ -5591,7 +5591,7 @@ std::unique_ptr<GeomCurve> makeFromCurveAdaptor(const Adaptor3d_Curve& adapt)
}
case GeomAbs_Hyperbola:
{
geoCurve.reset(new GeomHyperbola());
geoCurve = std::make_unique<GeomHyperbola>();
Handle(Geom_Hyperbola) this_curv = Handle(Geom_Hyperbola)::DownCast
(geoCurve->handle());
this_curv->SetHypr(adapt.Hyperbola());
@@ -5599,7 +5599,7 @@ std::unique_ptr<GeomCurve> makeFromCurveAdaptor(const Adaptor3d_Curve& adapt)
}
case GeomAbs_Parabola:
{
geoCurve.reset(new GeomParabola());
geoCurve = std::make_unique<GeomParabola>();
Handle(Geom_Parabola) this_curv = Handle(Geom_Parabola)::DownCast
(geoCurve->handle());
this_curv->SetParab(adapt.Parabola());
@@ -5607,17 +5607,17 @@ std::unique_ptr<GeomCurve> makeFromCurveAdaptor(const Adaptor3d_Curve& adapt)
}
case GeomAbs_BezierCurve:
{
geoCurve.reset(new GeomBezierCurve(adapt.Bezier()));
geoCurve = std::make_unique<GeomBezierCurve>(adapt.Bezier());
break;
}
case GeomAbs_BSplineCurve:
{
geoCurve.reset(new GeomBSplineCurve(adapt.BSpline()));
geoCurve = std::make_unique<GeomBSplineCurve>(adapt.BSpline());
break;
}
case GeomAbs_OffsetCurve:
{
geoCurve.reset(new GeomOffsetCurve(adapt.OffsetCurve()));
geoCurve = std::make_unique<GeomOffsetCurve>(adapt.OffsetCurve());
break;
}
case GeomAbs_OtherCurve:

View File

@@ -2304,28 +2304,28 @@ std::unique_ptr<Geom2dCurve> makeFromCurve2d(Handle(Geom2d_Curve) curve)
if (curve.IsNull())
return geo2d;
if (curve->IsKind(STANDARD_TYPE (Geom2d_Parabola))) {
geo2d.reset(new Geom2dParabola(Handle(Geom2d_Parabola)::DownCast(curve)));
geo2d = std::make_unique<Geom2dParabola>(Handle(Geom2d_Parabola)::DownCast(curve));
}
else if (curve->IsKind(STANDARD_TYPE (Geom2d_Hyperbola))) {
geo2d.reset(new Geom2dHyperbola(Handle(Geom2d_Hyperbola)::DownCast(curve)));
geo2d = std::make_unique<Geom2dHyperbola>(Handle(Geom2d_Hyperbola)::DownCast(curve));
}
else if (curve->IsKind(STANDARD_TYPE (Geom2d_Ellipse))) {
geo2d.reset(new Geom2dEllipse(Handle(Geom2d_Ellipse)::DownCast(curve)));
geo2d = std::make_unique<Geom2dEllipse>(Handle(Geom2d_Ellipse)::DownCast(curve));
}
else if (curve->IsKind(STANDARD_TYPE (Geom2d_Circle))) {
geo2d.reset(new Geom2dCircle(Handle(Geom2d_Circle)::DownCast(curve)));
geo2d = std::make_unique<Geom2dCircle>(Handle(Geom2d_Circle)::DownCast(curve));
}
else if (curve->IsKind(STANDARD_TYPE (Geom2d_Line))) {
geo2d.reset(new Geom2dLine(Handle(Geom2d_Line)::DownCast(curve)));
geo2d = std::make_unique<Geom2dLine>(Handle(Geom2d_Line)::DownCast(curve));
}
else if (curve->IsKind(STANDARD_TYPE (Geom2d_BSplineCurve))) {
geo2d.reset(new Geom2dBSplineCurve(Handle(Geom2d_BSplineCurve)::DownCast(curve)));
geo2d = std::make_unique<Geom2dBSplineCurve>(Handle(Geom2d_BSplineCurve)::DownCast(curve));
}
else if (curve->IsKind(STANDARD_TYPE (Geom2d_BezierCurve))) {
geo2d.reset(new Geom2dBezierCurve(Handle(Geom2d_BezierCurve)::DownCast(curve)));
geo2d = std::make_unique<Geom2dBezierCurve>(Handle(Geom2d_BezierCurve)::DownCast(curve));
}
else if (curve->IsKind(STANDARD_TYPE (Geom2d_TrimmedCurve))) {
geo2d.reset(new Geom2dTrimmedCurve(Handle(Geom2d_TrimmedCurve)::DownCast(curve)));
geo2d = std::make_unique<Geom2dTrimmedCurve>(Handle(Geom2d_TrimmedCurve)::DownCast(curve));
}
return geo2d;
@@ -2426,7 +2426,7 @@ std::unique_ptr<Geom2dCurve> makeFromCurveAdaptor2d(const Adaptor2d_Curve2d& ada
{
case GeomAbs_Line:
{
geoCurve.reset(new Geom2dLine());
geoCurve = std::make_unique<Geom2dLine>();
Handle(Geom2d_Line) this_curv = Handle(Geom2d_Line)::DownCast
(geoCurve->handle());
this_curv->SetLin2d(adapt.Line());
@@ -2434,7 +2434,7 @@ std::unique_ptr<Geom2dCurve> makeFromCurveAdaptor2d(const Adaptor2d_Curve2d& ada
}
case GeomAbs_Circle:
{
geoCurve.reset(new Geom2dCircle());
geoCurve = std::make_unique<Geom2dCircle>();
Handle(Geom2d_Circle) this_curv = Handle(Geom2d_Circle)::DownCast
(geoCurve->handle());
this_curv->SetCirc2d(adapt.Circle());
@@ -2442,7 +2442,7 @@ std::unique_ptr<Geom2dCurve> makeFromCurveAdaptor2d(const Adaptor2d_Curve2d& ada
}
case GeomAbs_Ellipse:
{
geoCurve.reset(new Geom2dEllipse());
geoCurve = std::make_unique<Geom2dEllipse>();
Handle(Geom2d_Ellipse) this_curv = Handle(Geom2d_Ellipse)::DownCast
(geoCurve->handle());
this_curv->SetElips2d(adapt.Ellipse());
@@ -2450,7 +2450,7 @@ std::unique_ptr<Geom2dCurve> makeFromCurveAdaptor2d(const Adaptor2d_Curve2d& ada
}
case GeomAbs_Hyperbola:
{
geoCurve.reset(new Geom2dHyperbola());
geoCurve = std::make_unique<Geom2dHyperbola>();
Handle(Geom2d_Hyperbola) this_curv = Handle(Geom2d_Hyperbola)::DownCast
(geoCurve->handle());
this_curv->SetHypr2d(adapt.Hyperbola());
@@ -2458,7 +2458,7 @@ std::unique_ptr<Geom2dCurve> makeFromCurveAdaptor2d(const Adaptor2d_Curve2d& ada
}
case GeomAbs_Parabola:
{
geoCurve.reset(new Geom2dParabola());
geoCurve = std::make_unique<Geom2dParabola>();
Handle(Geom2d_Parabola) this_curv = Handle(Geom2d_Parabola)::DownCast
(geoCurve->handle());
this_curv->SetParab2d(adapt.Parabola());
@@ -2466,12 +2466,12 @@ std::unique_ptr<Geom2dCurve> makeFromCurveAdaptor2d(const Adaptor2d_Curve2d& ada
}
case GeomAbs_BezierCurve:
{
geoCurve.reset(new Geom2dBezierCurve(adapt.Bezier()));
geoCurve = std::make_unique<Geom2dBezierCurve>(adapt.Bezier());
break;
}
case GeomAbs_BSplineCurve:
{
geoCurve.reset(new Geom2dBSplineCurve(adapt.BSpline()));
geoCurve = std::make_unique<Geom2dBSplineCurve>(adapt.BSpline());
break;
}
case GeomAbs_OtherCurve:

View File

@@ -170,7 +170,7 @@ SoBrepFaceSet::SoBrepFaceSet()
selContext2 = std::make_shared<SelContext>();
packedColor = 0;
pimpl.reset(new VBO);
pimpl = std::make_unique<VBO>();
}
SoBrepFaceSet::~SoBrepFaceSet()

View File

@@ -188,7 +188,7 @@ Area::Area(const Area& other, bool deep_copy)
if (!deep_copy || !other.isBuilt())
return;
if (other.myArea)
myArea.reset(new CArea(*other.myArea));
myArea = std::make_unique<CArea>(*other.myArea);
myShapePlane = other.myShapePlane;
myShape = other.myShape;
myShapeDone = other.myShapeDone;
@@ -1637,8 +1637,8 @@ void Area::build() {
getPlane(&trsf);
try {
myArea.reset(new CArea());
myAreaOpen.reset(new CArea());
myArea = std::make_unique<CArea>();
myAreaOpen = std::make_unique<CArea>();
CAreaConfig conf(myParams);
CArea areaClip;

View File

@@ -90,17 +90,17 @@ private:
std::unique_ptr<Reader> reader;
if (file.hasExtension("asc")) {
reader.reset(new AscReader);
reader = std::make_unique<AscReader>();
}
else if (file.hasExtension("e57")) {
auto setting = readE57Settings();
reader.reset(new E57Reader(std::get<0>(setting), std::get<1>(setting), std::get<2>(setting)));
reader = std::make_unique<E57Reader>(std::get<0>(setting), std::get<1>(setting), std::get<2>(setting));
}
else if (file.hasExtension("ply")) {
reader.reset(new PlyReader);
reader = std::make_unique<PlyReader>();
}
else if (file.hasExtension("pcd")) {
reader.reset(new PcdReader);
reader = std::make_unique<PcdReader>();
}
else {
throw Py::RuntimeError("Unsupported file extension");
@@ -206,17 +206,17 @@ private:
std::unique_ptr<Reader> reader;
if (file.hasExtension("asc")) {
reader.reset(new AscReader);
reader = std::make_unique<AscReader>();
}
else if (file.hasExtension("e57")) {
auto setting = readE57Settings();
reader.reset(new E57Reader(std::get<0>(setting), std::get<1>(setting), std::get<2>(setting)));
reader = std::make_unique<E57Reader>(std::get<0>(setting), std::get<1>(setting), std::get<2>(setting));
}
else if (file.hasExtension("ply")) {
reader.reset(new PlyReader);
reader = std::make_unique<PlyReader>();
}
else if (file.hasExtension("pcd")) {
reader.reset(new PcdReader);
reader = std::make_unique<PcdReader>();
}
else {
throw Py::RuntimeError("Unsupported file extension");
@@ -327,13 +327,13 @@ private:
const PointKernel& kernel = fea->Points.getValue();
std::unique_ptr<Writer> writer;
if (file.hasExtension("asc")) {
writer.reset(new AscWriter(kernel));
writer = std::make_unique<AscWriter>(kernel);
}
else if (file.hasExtension("ply")) {
writer.reset(new PlyWriter(kernel));
writer = std::make_unique<PlyWriter>(kernel);
}
else if (file.hasExtension("pcd")) {
writer.reset(new PcdWriter(kernel));
writer = std::make_unique<PcdWriter>(kernel);
}
else {
throw Py::RuntimeError("Unsupported file extension");

View File

@@ -179,10 +179,10 @@ void Trajectory::generateTrajectory()
bool Cont = (*it)->Cont && !(it == --vpcWaypoints.end());
// start of a continue block
if (Cont && !pcRoundComp) {
pcRoundComp.reset(new KDL::Path_RoundedComposite(3, 3,
new KDL::RotationalInterpolation_SingleAxis()));
pcRoundComp = std::make_unique<KDL::Path_RoundedComposite>(3, 3,
new KDL::RotationalInterpolation_SingleAxis());
// the velocity of the first waypoint is used
pcVelPrf.reset(new KDL::VelocityProfile_Trap((*it)->Velocity, (*it)->Acceleration));
pcVelPrf = std::make_unique<KDL::VelocityProfile_Trap>((*it)->Velocity, (*it)->Acceleration);
pcRoundComp->Add(Last);
pcRoundComp->Add(Next);
@@ -197,7 +197,7 @@ void Trajectory::generateTrajectory()
pcRoundComp->Add(Next);
pcRoundComp->Finish();
pcVelPrf->SetProfile(0, pcRoundComp->PathLength());
pcTrak.reset(new KDL::Trajectory_Segment(pcRoundComp.release(), pcVelPrf.release()));
pcTrak = std::make_unique<KDL::Trajectory_Segment>(pcRoundComp.release(), pcVelPrf.release());
// normal block
}
@@ -210,9 +210,9 @@ void Trajectory::generateTrajectory()
true
);
pcVelPrf.reset(new KDL::VelocityProfile_Trap((*it)->Velocity, (*it)->Acceleration));
pcVelPrf = std::make_unique<KDL::VelocityProfile_Trap>((*it)->Velocity, (*it)->Acceleration);
pcVelPrf->SetProfile(0, pcPath->PathLength());
pcTrak.reset(new KDL::Trajectory_Segment(pcPath, pcVelPrf.release()));
pcTrak = std::make_unique<KDL::Trajectory_Segment>(pcPath, pcVelPrf.release());
}
Last = Next;
break; }

View File

@@ -283,7 +283,7 @@ void Cell::setContent(const char * value)
if (owner->sheet()->isRestoring()) {
if (value[0] == '\0' || (value[0] == '\'' && value[1] == '\0'))
return;
expression.reset(new App::StringExpression(owner->sheet(), value));
expression = std::make_unique<App::StringExpression>(owner->sheet(), value);
setUsed(EXPRESSION_SET, true);
return;
}

View File

@@ -675,7 +675,7 @@ void Sheet::updateProperty(CellAddress key)
std::string s;
if (cell->getStringContent(s) && !s.empty())
output.reset(new StringExpression(this, s));
output = std::make_unique<StringExpression>(this, s);
else {
this->removeDynamicProperty(key.toString().c_str());
return;