Sketcher: Fixes #14240
This commit is contained in:
@@ -445,21 +445,18 @@ void SketchAnalysis::analyseMissingPointOnPointCoincident(double angleprecision)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SketchAnalysis::makeMissingPointOnPointCoincident(bool onebyone)
|
||||
{
|
||||
int status, dofs;
|
||||
std::vector<Sketcher::Constraint*> constr;
|
||||
|
||||
for (std::vector<Sketcher::ConstraintIds>::iterator it = vertexConstraints.begin();
|
||||
it != vertexConstraints.end();
|
||||
++it) {
|
||||
for (const auto& it : vertexConstraints) {
|
||||
Sketcher::Constraint* c = new Sketcher::Constraint();
|
||||
c->Type = it->Type;
|
||||
c->First = it->First;
|
||||
c->Second = it->Second;
|
||||
c->FirstPos = it->FirstPos;
|
||||
c->SecondPos = it->SecondPos;
|
||||
c->Type = it.Type;
|
||||
c->First = it.First;
|
||||
c->Second = it.Second;
|
||||
c->FirstPos = it.FirstPos;
|
||||
c->SecondPos = it.SecondPos;
|
||||
|
||||
if (onebyone) {
|
||||
// addConstraint() creates a clone
|
||||
@@ -492,9 +489,8 @@ void SketchAnalysis::makeMissingPointOnPointCoincident(bool onebyone)
|
||||
|
||||
vertexConstraints.clear();
|
||||
|
||||
for (std::vector<Sketcher::Constraint*>::iterator it = constr.begin(); it != constr.end();
|
||||
++it) {
|
||||
delete *it;
|
||||
for (auto it : constr) {
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9837,6 +9837,16 @@ void SketchObject::makeMissingEquality(bool onebyone)
|
||||
analyser->makeMissingEquality(onebyone);
|
||||
}
|
||||
|
||||
int SketchObject::detectDegeneratedGeometries(double tolerance)
|
||||
{
|
||||
return analyser->detectDegeneratedGeometries(tolerance);
|
||||
}
|
||||
|
||||
int SketchObject::removeDegeneratedGeometries(double tolerance)
|
||||
{
|
||||
return analyser->removeDegeneratedGeometries(tolerance);
|
||||
}
|
||||
|
||||
int SketchObject::autoRemoveRedundants(bool updategeo)
|
||||
{
|
||||
auto redundants = getLastRedundant();
|
||||
|
||||
@@ -750,6 +750,11 @@ public:
|
||||
void makeMissingVerticalHorizontal(bool onebyone = false);
|
||||
void makeMissingEquality(bool onebyone = true);
|
||||
|
||||
/// Detect degenerated geometries
|
||||
int detectDegeneratedGeometries(double tolerance);
|
||||
/// Remove degenerated geometries
|
||||
int removeDegeneratedGeometries(double tolerance);
|
||||
|
||||
// helper
|
||||
/// returns the number of redundant constraints detected
|
||||
int autoRemoveRedundants(bool updategeo = true);
|
||||
|
||||
@@ -59,7 +59,6 @@ SketcherValidation::SketcherValidation(Sketcher::SketchObject* Obj, QWidget* par
|
||||
: QWidget(parent)
|
||||
, ui(new Ui_TaskSketcherValidation())
|
||||
, sketch(Obj)
|
||||
, sketchAnalyser(Obj)
|
||||
, coincidenceRoot(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -160,12 +159,11 @@ void SketcherValidation::onFindButtonClicked()
|
||||
}
|
||||
}
|
||||
|
||||
sketchAnalyser.detectMissingPointOnPointConstraints(
|
||||
prec,
|
||||
!ui->checkBoxIgnoreConstruction->isChecked());
|
||||
sketch->detectMissingPointOnPointConstraints(prec,
|
||||
!ui->checkBoxIgnoreConstruction->isChecked());
|
||||
|
||||
std::vector<Sketcher::ConstraintIds>& vertexConstraints =
|
||||
sketchAnalyser.getMissingPointOnPointConstraints();
|
||||
sketch->getMissingPointOnPointConstraints();
|
||||
|
||||
std::vector<Base::Vector3d> points;
|
||||
points.reserve(vertexConstraints.size());
|
||||
@@ -222,7 +220,7 @@ void SketcherValidation::onHighlightButtonClicked()
|
||||
|
||||
std::vector<Base::Vector3d> points;
|
||||
|
||||
points = sketchAnalyser.getOpenVertices();
|
||||
points = sketch->getOpenVertices();
|
||||
|
||||
hidePoints();
|
||||
if (!points.empty()) {
|
||||
@@ -475,7 +473,7 @@ void SketcherValidation::onFindDegeneratedClicked()
|
||||
}
|
||||
|
||||
double prec = Precision::Confusion();
|
||||
int count = sketchAnalyser.detectDegeneratedGeometries(prec);
|
||||
int count = sketch->detectDegeneratedGeometries(prec);
|
||||
|
||||
if (count == 0) {
|
||||
Gui::TranslatedNotification(*sketch,
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <App/DocumentObserver.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Mod/Sketcher/App/SketchAnalysis.h>
|
||||
|
||||
|
||||
class SoGroup;
|
||||
@@ -75,7 +74,6 @@ private:
|
||||
private:
|
||||
std::unique_ptr<Ui_TaskSketcherValidation> ui;
|
||||
App::WeakPtrT<Sketcher::SketchObject> sketch;
|
||||
Sketcher::SketchAnalysis sketchAnalyser;
|
||||
SoGroup* coincidenceRoot;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user