Part_Loft add ability to use a Facefor a profile

Part Loft internally uses either a vertices and/or wires as profiles.
If an edge is selected always was converted into a wire for MakeLoft.
This commit allows a face to be selected and then uses
ShapeAnalysis::OuterWire
to aquire a wire (from the outer edges of the face) to pass to MakeLoft.
This commit is contained in:
jmaustpc 2013-03-08 00:48:08 +11:00 committed by Yorik van Havre
parent 5fc802dfa1
commit 0a7a9d9cf2
2 changed files with 11 additions and 5 deletions

View File

@ -29,6 +29,7 @@
# include <TopoDS_Shell.hxx>
# include <BRepBuilderAPI_MakeWire.hxx>
# include <BRepOffsetAPI_MakePipeShell.hxx>
# include <ShapeAnalysis.hxx>
# include <TopTools_ListIteratorOfListOfShape.hxx>
# include <TopExp_Explorer.hxx>
# include <Precision.hxx>
@ -173,7 +174,11 @@ App::DocumentObjectExecReturn *Loft::execute(void)
const TopoDS_Shape& shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
if (shape.IsNull())
return new App::DocumentObjectExecReturn("Linked shape is invalid.");
if (shape.ShapeType() == TopAbs_WIRE) {
if (shape.ShapeType() == TopAbs_FACE) {
TopoDS_Wire faceouterWire = ShapeAnalysis::OuterWire(TopoDS::Face(shape));
profiles.Append(faceouterWire);
}
else if (shape.ShapeType() == TopAbs_WIRE) {
profiles.Append(shape);
}
else if (shape.ShapeType() == TopAbs_EDGE) {

View File

@ -69,7 +69,7 @@ LoftWidget::LoftWidget(QWidget* parent)
Gui::Application::Instance->runPythonCode("import Part");
d->ui.setupUi(this);
d->ui.selector->setAvailableLabel(tr("Vertex/Wire"));
d->ui.selector->setAvailableLabel(tr("Vertex/Wire/Face"));
d->ui.selector->setSelectedLabel(tr("Loft"));
connect(d->ui.selector->availableTreeWidget(), SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
@ -98,7 +98,8 @@ void LoftWidget::findShapes()
const TopoDS_Shape& shape = (*it)->Shape.getValue();
if (shape.IsNull()) continue;
if (shape.ShapeType() == TopAbs_WIRE ||
if (shape.ShapeType() == TopAbs_FACE ||
shape.ShapeType() == TopAbs_WIRE ||
shape.ShapeType() == TopAbs_EDGE ||
shape.ShapeType() == TopAbs_VERTEX) {
QString label = QString::fromUtf8((*it)->Label.getValue());
@ -132,7 +133,7 @@ bool LoftWidget::accept()
int count = d->ui.selector->selectedTreeWidget()->topLevelItemCount();
if (count < 2) {
QMessageBox::critical(this, tr("Too few elements"), tr("At least two vertices, edges or wires are required."));
QMessageBox::critical(this, tr("Too few elements"), tr("At least two vertices, edges, wires or Faces are required."));
return false;
}
for (int i=0; i<count; i++) {
@ -187,7 +188,7 @@ void LoftWidget::changeEvent(QEvent *e)
QWidget::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
d->ui.retranslateUi(this);
d->ui.selector->setAvailableLabel(tr("Vertex/Wire"));
d->ui.selector->setAvailableLabel(tr("Vertex/Wire/Face"));
d->ui.selector->setSelectedLabel(tr("Loft"));
}
}