+ allow to select whole wire in sweep panel
This commit is contained in:
parent
ce3a503bd6
commit
51b2af52fd
|
@ -31,9 +31,11 @@
|
|||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Shell.hxx>
|
||||
# include <TopTools_HSequenceOfShape.hxx>
|
||||
# include <BRepBuilderAPI_MakeWire.hxx>
|
||||
# include <BRepOffsetAPI_MakePipeShell.hxx>
|
||||
# include <ShapeAnalysis.hxx>
|
||||
# include <ShapeAnalysis_FreeBounds.hxx>
|
||||
# include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
# include <TopoDS_Iterator.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
|
@ -339,14 +341,14 @@ App::DocumentObjectExecReturn *Sweep::execute(void)
|
|||
const Part::TopoShape& shape = static_cast<Part::Feature*>(spine)->Shape.getValue();
|
||||
if (!shape._Shape.IsNull()) {
|
||||
try {
|
||||
BRepBuilderAPI_MakeWire mkWire;
|
||||
for (std::vector<std::string>::const_iterator it = subedge.begin(); it != subedge.end(); ++it) {
|
||||
TopoDS_Shape subshape = shape.getSubShape(it->c_str());
|
||||
mkWire.Add(TopoDS::Edge(subshape));
|
||||
if (!subedge.empty()) {
|
||||
BRepBuilderAPI_MakeWire mkWire;
|
||||
for (std::vector<std::string>::const_iterator it = subedge.begin(); it != subedge.end(); ++it) {
|
||||
TopoDS_Shape subshape = shape.getSubShape(it->c_str());
|
||||
mkWire.Add(TopoDS::Edge(subshape));
|
||||
}
|
||||
path = mkWire.Wire();
|
||||
}
|
||||
path = mkWire.Wire();
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
if (shape._Shape.ShapeType() == TopAbs_EDGE) {
|
||||
path = shape._Shape;
|
||||
}
|
||||
|
@ -354,10 +356,35 @@ App::DocumentObjectExecReturn *Sweep::execute(void)
|
|||
BRepBuilderAPI_MakeWire mkWire(TopoDS::Wire(shape._Shape));
|
||||
path = mkWire.Wire();
|
||||
}
|
||||
else if (shape._Shape.ShapeType() == TopAbs_COMPOUND) {
|
||||
TopoDS_Iterator it(shape._Shape);
|
||||
for (; it.More(); it.Next()) {
|
||||
if (it.Value().IsNull())
|
||||
return new App::DocumentObjectExecReturn("In valid element in spine.");
|
||||
if ((it.Value().ShapeType() != TopAbs_EDGE) &&
|
||||
(it.Value().ShapeType() != TopAbs_WIRE)) {
|
||||
return new App::DocumentObjectExecReturn("Element in spine is neither an edge nor a wire.");
|
||||
}
|
||||
}
|
||||
|
||||
Handle(TopTools_HSequenceOfShape) hEdges = new TopTools_HSequenceOfShape();
|
||||
Handle(TopTools_HSequenceOfShape) hWires = new TopTools_HSequenceOfShape();
|
||||
for (TopExp_Explorer xp(shape._Shape, TopAbs_EDGE); xp.More(); xp.Next())
|
||||
hEdges->Append(xp.Current());
|
||||
|
||||
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, Precision::Confusion(), Standard_True, hWires);
|
||||
int len = hWires->Length();
|
||||
if (len != 1)
|
||||
return new App::DocumentObjectExecReturn("Spine is not connected.");
|
||||
path = hWires->Value(1);
|
||||
}
|
||||
else {
|
||||
return new App::DocumentObjectExecReturn("Spine is neither an edge nor a wire.");
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
return new App::DocumentObjectExecReturn("Invalid spine.");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<UserDocu>Add a shape to the compound.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="connectEdgesToWires">
|
||||
<Methode Name="connectEdgesToWires" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Build a compound of wires out of the edges of this compound.</UserDocu>
|
||||
</Documentation>
|
||||
|
|
|
@ -28,8 +28,12 @@
|
|||
# include <QMessageBox>
|
||||
# include <QTextStream>
|
||||
# include <BRepBuilderAPI_MakeWire.hxx>
|
||||
# include <Precision.hxx>
|
||||
# include <ShapeAnalysis_FreeBounds.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Iterator.hxx>
|
||||
# include <TopTools_HSequenceOfShape.hxx>
|
||||
#endif
|
||||
|
||||
#include "ui_TaskSweep.h"
|
||||
|
@ -41,6 +45,7 @@
|
|||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
|
@ -81,10 +86,27 @@ public:
|
|||
// shape is an edge or wire we can use it completely.
|
||||
const TopoDS_Shape& shape = static_cast<Part::Feature*>(pObj)->Shape.getValue();
|
||||
if (!shape.IsNull()) {
|
||||
if (shape.ShapeType() == TopAbs_EDGE)
|
||||
// a single edge
|
||||
if (shape.ShapeType() == TopAbs_EDGE) {
|
||||
return true;
|
||||
if (shape.ShapeType() == TopAbs_WIRE)
|
||||
}
|
||||
// a single wire
|
||||
if (shape.ShapeType() == TopAbs_WIRE) {
|
||||
return true;
|
||||
}
|
||||
// a compound of only edges or wires
|
||||
if (shape.ShapeType() == TopAbs_COMPOUND) {
|
||||
TopoDS_Iterator it(shape);
|
||||
for (; it.More(); it.Next()) {
|
||||
if (it.Value().IsNull())
|
||||
return false;
|
||||
if ((it.Value().ShapeType() != TopAbs_EDGE) &&
|
||||
(it.Value().ShapeType() != TopAbs_WIRE))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -199,6 +221,30 @@ bool SweepWidget::isPathValid(const Gui::SelectionObject& sel) const
|
|||
BRepBuilderAPI_MakeWire mkWire(TopoDS::Wire(shape._Shape));
|
||||
pathShape = mkWire.Wire();
|
||||
}
|
||||
else if (shape._Shape.ShapeType() == TopAbs_COMPOUND) {
|
||||
try {
|
||||
TopoDS_Iterator it(shape._Shape);
|
||||
for (; it.More(); it.Next()) {
|
||||
if ((it.Value().ShapeType() != TopAbs_EDGE) &&
|
||||
(it.Value().ShapeType() != TopAbs_WIRE)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Handle(TopTools_HSequenceOfShape) hEdges = new TopTools_HSequenceOfShape();
|
||||
Handle(TopTools_HSequenceOfShape) hWires = new TopTools_HSequenceOfShape();
|
||||
for (TopExp_Explorer xp(shape._Shape, TopAbs_EDGE); xp.More(); xp.Next())
|
||||
hEdges->Append(xp.Current());
|
||||
|
||||
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, Precision::Confusion(), Standard_True, hWires);
|
||||
int len = hWires->Length();
|
||||
if (len != 1)
|
||||
return false;
|
||||
pathShape = hWires->Value(1);
|
||||
}
|
||||
catch (...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return (!pathShape.IsNull());
|
||||
}
|
||||
|
@ -255,6 +301,7 @@ bool SweepWidget::accept()
|
|||
}
|
||||
|
||||
try {
|
||||
Gui::WaitCursor wc;
|
||||
QString cmd;
|
||||
cmd = QString::fromAscii(
|
||||
"App.getDocument('%5').addObject('Part::Sweep','Sweep')\n"
|
||||
|
|
Loading…
Reference in New Issue
Block a user