Add function to sketch validation panel to highlight open vertexes

This commit is contained in:
wmayer 2016-08-07 15:30:09 +02:00
parent b32e1aae11
commit a0d7c8bd21
3 changed files with 40 additions and 3 deletions

View File

@ -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"
@ -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()) {

View File

@ -49,6 +49,7 @@ protected:
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();

View File

@ -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>
@ -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>