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());
}
}