diff --git a/src/Mod/Mesh/App/Core/Approximation.cpp b/src/Mod/Mesh/App/Core/Approximation.cpp
index d34b7f894d..0c7521907b 100644
--- a/src/Mod/Mesh/App/Core/Approximation.cpp
+++ b/src/Mod/Mesh/App/Core/Approximation.cpp
@@ -30,6 +30,7 @@
#endif
#include "Approximation.h"
+#include "Elements.h"
#include "Utilities.h"
#include
@@ -97,6 +98,12 @@ void Approximation::AddPoints(const std::list &points)
_bIsFitted = false;
}
+void Approximation::AddPoints(const MeshPointArray &points)
+{
+ std::copy(points.begin(), points.end(), std::back_inserter(_vPoints));
+ _bIsFitted = false;
+}
+
Base::Vector3f Approximation::GetGravity() const
{
Base::Vector3f clGravity;
diff --git a/src/Mod/Mesh/App/Core/Approximation.h b/src/Mod/Mesh/App/Core/Approximation.h
index 9ce2911593..168eb06e70 100644
--- a/src/Mod/Mesh/App/Core/Approximation.h
+++ b/src/Mod/Mesh/App/Core/Approximation.h
@@ -94,6 +94,7 @@ protected:
}
namespace MeshCore {
+class MeshPointArray;
/**
* Abstract base class for approximation of a geometry to a given set of points.
@@ -125,6 +126,10 @@ public:
* Add points for the fit algorithm.
*/
void AddPoints(const std::list &rsPointList);
+ /**
+ * Add points for the fit algorithm.
+ */
+ void AddPoints(const MeshPointArray &points);
/**
* Get all added points.
*/
diff --git a/src/Mod/Mesh/App/Core/Segmentation.cpp b/src/Mod/Mesh/App/Core/Segmentation.cpp
index 983d8c6da9..c0f693fee5 100644
--- a/src/Mod/Mesh/App/Core/Segmentation.cpp
+++ b/src/Mod/Mesh/App/Core/Segmentation.cpp
@@ -471,7 +471,7 @@ bool MeshSurfaceVisitor::Visit (const MeshFacet & face, const MeshFacet &,
// --------------------------------------------------------
-void MeshSegmentAlgorithm::FindSegments(std::vector& segm)
+void MeshSegmentAlgorithm::FindSegments(std::vector& segm)
{
// reset VISIT flags
unsigned long startFacet;
@@ -487,7 +487,7 @@ void MeshSegmentAlgorithm::FindSegments(std::vector& segm)
cAlgo.CountFacetFlag(MeshCore::MeshFacet::VISIT);
std::vector resetVisited;
- for (std::vector::iterator it = segm.begin(); it != segm.end(); ++it) {
+ for (std::vector::iterator it = segm.begin(); it != segm.end(); ++it) {
cAlgo.ResetFacetsFlag(resetVisited, MeshCore::MeshFacet::VISIT);
resetVisited.clear();
diff --git a/src/Mod/Mesh/App/Core/Segmentation.h b/src/Mod/Mesh/App/Core/Segmentation.h
index d2ac9715cf..e1fe5d28d8 100644
--- a/src/Mod/Mesh/App/Core/Segmentation.h
+++ b/src/Mod/Mesh/App/Core/Segmentation.h
@@ -27,6 +27,7 @@
#include "Curvature.h"
#include "Visitor.h"
#include
+#include
namespace MeshCore {
@@ -55,6 +56,7 @@ protected:
std::vector segments;
unsigned long minFacets;
};
+typedef std::shared_ptr MeshSurfaceSegmentPtr;
// --------------------------------------------------------
@@ -263,7 +265,7 @@ class MeshExport MeshSegmentAlgorithm
{
public:
MeshSegmentAlgorithm(const MeshKernel& kernel) : myKernel(kernel) {}
- void FindSegments(std::vector&);
+ void FindSegments(std::vector&);
private:
const MeshKernel& myKernel;
diff --git a/src/Mod/Mesh/App/Mesh.cpp b/src/Mod/Mesh/App/Mesh.cpp
index 5864e6d93d..8288447d37 100644
--- a/src/Mod/Mesh/App/Mesh.cpp
+++ b/src/Mod/Mesh/App/Mesh.cpp
@@ -1804,7 +1804,7 @@ std::vector MeshObject::getSegmentsOfType(MeshObject::GeometryType type
return segm;
MeshCore::MeshSegmentAlgorithm finder(this->_kernel);
- std::unique_ptr surf;
+ std::shared_ptr surf;
switch (type) {
case PLANE:
//surf.reset(new MeshCore::MeshDistancePlanarSegment(this->_kernel, minFacets, dev));
@@ -1824,8 +1824,8 @@ std::vector MeshObject::getSegmentsOfType(MeshObject::GeometryType type
}
if (surf.get()) {
- std::vector surfaces;
- surfaces.push_back(surf.get());
+ std::vector surfaces;
+ surfaces.push_back(surf);
finder.FindSegments(surfaces);
const std::vector& data = surf->GetSegments();
diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp
index eac9b096ac..08037f771d 100644
--- a/src/Mod/Mesh/App/MeshPyImp.cpp
+++ b/src/Mod/Mesh/App/MeshPyImp.cpp
@@ -1887,7 +1887,7 @@ PyObject* MeshPy::getSegmentsByCurvature(PyObject *args)
meshCurv.ComputePerVertex();
Py::Sequence func(l);
- std::vector segm;
+ std::vector segm;
for (Py::Sequence::iterator it = func.begin(); it != func.end(); ++it) {
Py::Tuple t(*it);
float c1 = (float)Py::Float(t[0]);
@@ -1899,13 +1899,13 @@ PyObject* MeshPy::getSegmentsByCurvature(PyObject *args)
#else
int num = (int)Py::Int(t[4]);
#endif
- segm.push_back(new MeshCore::MeshCurvatureFreeformSegment(meshCurv.GetCurvature(), num, tol1, tol2, c1, c2));
+ segm.emplace_back(new MeshCore::MeshCurvatureFreeformSegment(meshCurv.GetCurvature(), num, tol1, tol2, c1, c2));
}
finder.FindSegments(segm);
Py::List list;
- for (std::vector::iterator segmIt = segm.begin(); segmIt != segm.end(); ++segmIt) {
+ for (std::vector::iterator segmIt = segm.begin(); segmIt != segm.end(); ++segmIt) {
const std::vector& data = (*segmIt)->GetSegments();
for (std::vector::const_iterator it = data.begin(); it != data.end(); ++it) {
Py::List ary;
@@ -1918,7 +1918,6 @@ PyObject* MeshPy::getSegmentsByCurvature(PyObject *args)
}
list.append(ary);
}
- delete (*segmIt);
}
return Py::new_reference_to(list);
diff --git a/src/Mod/Mesh/Gui/Segmentation.cpp b/src/Mod/Mesh/Gui/Segmentation.cpp
index 3fe27d7975..7a8e62e117 100644
--- a/src/Mod/Mesh/Gui/Segmentation.cpp
+++ b/src/Mod/Mesh/Gui/Segmentation.cpp
@@ -83,23 +83,23 @@ void Segmentation::accept()
MeshCore::MeshCurvature meshCurv(kernel);
meshCurv.ComputePerVertex();
- std::vector segm;
+ std::vector segm;
if (ui->groupBoxFree->isChecked()) {
- segm.push_back(new MeshCore::MeshCurvatureFreeformSegment
+ segm.emplace_back(new MeshCore::MeshCurvatureFreeformSegment
(meshCurv.GetCurvature(), ui->numFree->value(),
ui->tol1Free->value(), ui->tol2Free->value(),
ui->crv1Free->value(), ui->crv2Free->value()));
}
if (ui->groupBoxCyl->isChecked()) {
- segm.push_back(new MeshCore::MeshCurvatureCylindricalSegment
+ segm.emplace_back(new MeshCore::MeshCurvatureCylindricalSegment
(meshCurv.GetCurvature(), ui->numCyl->value(), ui->tol1Cyl->value(), ui->tol2Cyl->value(), ui->crvCyl->value()));
}
if (ui->groupBoxSph->isChecked()) {
- segm.push_back(new MeshCore::MeshCurvatureSphericalSegment
+ segm.emplace_back(new MeshCore::MeshCurvatureSphericalSegment
(meshCurv.GetCurvature(), ui->numSph->value(), ui->tolSph->value(), ui->crvSph->value()));
}
if (ui->groupBoxPln->isChecked()) {
- segm.push_back(new MeshCore::MeshCurvaturePlanarSegment
+ segm.emplace_back(new MeshCore::MeshCurvaturePlanarSegment
(meshCurv.GetCurvature(), ui->numPln->value(), ui->tolPln->value()));
}
finder.FindSegments(segm);
@@ -114,7 +114,7 @@ void Segmentation::accept()
std::string labelname = "Segments ";
labelname += myMesh->Label.getValue();
group->Label.setValue(labelname);
- for (std::vector::iterator it = segm.begin(); it != segm.end(); ++it) {
+ for (std::vector::iterator it = segm.begin(); it != segm.end(); ++it) {
const std::vector& data = (*it)->GetSegments();
for (std::vector::const_iterator jt = data.begin(); jt != data.end(); ++jt) {
Mesh::MeshObject* segment = mesh->meshFromSegment(*jt);
@@ -128,7 +128,6 @@ void Segmentation::accept()
label << feaSegm->Label.getValue() << " (" << (*it)->GetType() << ")";
feaSegm->Label.setValue(label.str());
}
- delete (*it);
}
document->commitTransaction();
}
diff --git a/src/Mod/Mesh/Gui/SegmentationBestFit.cpp b/src/Mod/Mesh/Gui/SegmentationBestFit.cpp
index 212f7fd28b..f8419d160b 100644
--- a/src/Mod/Mesh/Gui/SegmentationBestFit.cpp
+++ b/src/Mod/Mesh/Gui/SegmentationBestFit.cpp
@@ -382,7 +382,7 @@ void SegmentationBestFit::accept()
MeshCore::MeshSegmentAlgorithm finder(kernel);
- std::vector segm;
+ std::vector segm;
if (ui->groupBoxCyl->isChecked()) {
MeshCore::AbstractSurfaceFit* fitter;
if (cylinderParameter.size() == 7) {
@@ -395,7 +395,7 @@ void SegmentationBestFit::accept()
else {
fitter = new MeshCore::CylinderSurfaceFit;
}
- segm.push_back(new MeshCore::MeshDistanceGenericSurfaceFitSegment
+ segm.emplace_back(new MeshCore::MeshDistanceGenericSurfaceFitSegment
(fitter, kernel, ui->numCyl->value(), ui->tolCyl->value()));
}
if (ui->groupBoxSph->isChecked()) {
@@ -409,7 +409,7 @@ void SegmentationBestFit::accept()
else {
fitter = new MeshCore::SphereSurfaceFit;
}
- segm.push_back(new MeshCore::MeshDistanceGenericSurfaceFitSegment
+ segm.emplace_back(new MeshCore::MeshDistanceGenericSurfaceFitSegment
(fitter, kernel, ui->numSph->value(), ui->tolSph->value()));
}
if (ui->groupBoxPln->isChecked()) {
@@ -423,7 +423,7 @@ void SegmentationBestFit::accept()
else {
fitter = new MeshCore::PlaneSurfaceFit;
}
- segm.push_back(new MeshCore::MeshDistanceGenericSurfaceFitSegment
+ segm.emplace_back(new MeshCore::MeshDistanceGenericSurfaceFitSegment
(fitter, kernel, ui->numPln->value(), ui->tolPln->value()));
}
finder.FindSegments(segm);
@@ -438,7 +438,7 @@ void SegmentationBestFit::accept()
std::string labelname = "Segments ";
labelname += myMesh->Label.getValue();
group->Label.setValue(labelname);
- for (std::vector::iterator it = segm.begin(); it != segm.end(); ++it) {
+ for (std::vector::iterator it = segm.begin(); it != segm.end(); ++it) {
const std::vector& data = (*it)->GetSegments();
for (std::vector::const_iterator jt = data.begin(); jt != data.end(); ++jt) {
Mesh::MeshObject* segment = mesh->meshFromSegment(*jt);
@@ -452,7 +452,6 @@ void SegmentationBestFit::accept()
label << feaSegm->Label.getValue() << " (" << (*it)->GetType() << ")";
feaSegm->Label.setValue(label.str());
}
- delete (*it);
}
document->commitTransaction();
}