Skip to content

Commit

Permalink
Add function to sketch validation panel to highlight open vertexes
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Aug 7, 2016
1 parent b32e1aa commit a0d7c8b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
29 changes: 29 additions & 0 deletions src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp
Expand Up @@ -36,9 +36,16 @@
# include <Inventor/nodes/SoShapeHints.h>
#endif

#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <Precision.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <algorithm>

#include "ui_TaskSketcherValidation.h"
Expand Down Expand Up @@ -318,6 +325,28 @@ void SketcherValidation::on_fixButton_clicked()
doc->recompute();
}

void SketcherValidation::on_highlightButton_clicked()
{
std::vector<Base::Vector3d> points;
TopoDS_Shape shape = sketch->Shape.getValue();

// build up map vertex->edge
TopTools_IndexedDataMapOfShapeListOfShape vertex2Edge;
TopExp::MapShapesAndAncestors(shape, TopAbs_VERTEX, TopAbs_EDGE, vertex2Edge);
for (int i=1; i<= vertex2Edge.Extent(); ++i) {
const TopTools_ListOfShape& los = vertex2Edge.FindFromIndex(i);
if (los.Extent() != 2) {
const TopoDS_Vertex& vertex = TopoDS::Vertex(vertex2Edge.FindKey(i));
gp_Pnt pnt = BRep_Tool::Pnt(vertex);
points.push_back(Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z()));
}
}

hidePoints();
if (!points.empty())
showPoints(points);
}

void SketcherValidation::on_findConstraint_clicked()
{
if (sketch->evaluateConstraints()) {
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Sketcher/Gui/TaskSketcherValidation.h
Expand Up @@ -49,6 +49,7 @@ class SketcherValidation : public QWidget
private Q_SLOTS:
void on_findButton_clicked();
void on_fixButton_clicked();
void on_highlightButton_clicked();
void on_findConstraint_clicked();
void on_fixConstraint_clicked();
void on_findReversed_clicked();
Expand Down
13 changes: 10 additions & 3 deletions src/Mod/Sketcher/Gui/TaskSketcherValidation.ui
Expand Up @@ -57,6 +57,13 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="fixButton">
<property name="text">
<string>Fix</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxTolerance"/>
</item>
Expand All @@ -67,10 +74,10 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="fixButton">
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="highlightButton">
<property name="text">
<string>Fix</string>
<string>Highlight open vertexes</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit a0d7c8b

Please sign in to comment.