Skip to content

Commit

Permalink
+ fixes #1547: add Part Spiral to the selectable list of profiles for…
Browse files Browse the repository at this point in the history
… a Part Loft
  • Loading branch information
wwmayer committed May 15, 2014
1 parent f9ff3b2 commit 318c4b6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
27 changes: 25 additions & 2 deletions src/Mod/Part/App/PartFeatures.cpp
Expand Up @@ -35,6 +35,7 @@
# include <BRepOffsetAPI_MakePipeShell.hxx>
# include <ShapeAnalysis.hxx>
# include <TopTools_ListIteratorOfListOfShape.hxx>
# include <TopoDS_Iterator.hxx>
# include <TopExp_Explorer.hxx>
# include <TopoDS.hxx>
# include <Precision.hxx>
Expand Down Expand Up @@ -240,9 +241,20 @@ App::DocumentObjectExecReturn *Loft::execute(void)
for (it = shapes.begin(); it != shapes.end(); ++it) {
if (!(*it)->isDerivedFrom(Part::Feature::getClassTypeId()))
return new App::DocumentObjectExecReturn("Linked object is not a shape.");
const TopoDS_Shape& shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
TopoDS_Shape shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
if (shape.IsNull())
return new App::DocumentObjectExecReturn("Linked shape is invalid.");

// Extract first element of a compound
if (shape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(shape);
for (; it.More(); it.Next()) {
if (!it.Value().IsNull()) {
shape = it.Value();
break;
}
}
}
if (shape.ShapeType() == TopAbs_FACE) {
TopoDS_Wire faceouterWire = ShapeAnalysis::OuterWire(TopoDS::Face(shape));
profiles.Append(faceouterWire);
Expand Down Expand Up @@ -355,9 +367,20 @@ App::DocumentObjectExecReturn *Sweep::execute(void)
for (it = shapes.begin(); it != shapes.end(); ++it) {
if (!(*it)->isDerivedFrom(Part::Feature::getClassTypeId()))
return new App::DocumentObjectExecReturn("Linked object is not a shape.");
const TopoDS_Shape& shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
TopoDS_Shape shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
if (shape.IsNull())
return new App::DocumentObjectExecReturn("Linked shape is invalid.");

// Extract first element of a compound
if (shape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(shape);
for (; it.More(); it.Next()) {
if (!it.Value().IsNull()) {
shape = it.Value();
break;
}
}
}
// There is a weird behaviour of BRepOffsetAPI_MakePipeShell when trying to add the wire as is.
// If we re-create the wire then everything works fine.
// http://forum.freecadweb.org/viewtopic.php?f=10&t=2673&sid=fbcd2ff4589f0b2f79ed899b0b990648#p20268
Expand Down
17 changes: 16 additions & 1 deletion src/Mod/Part/Gui/TaskLoft.cpp
Expand Up @@ -26,6 +26,7 @@
#ifndef _PreComp_
# include <QMessageBox>
# include <QTextStream>
# include <TopoDS_Iterator.hxx>
#endif

#include "ui_TaskLoft.h"
Expand Down Expand Up @@ -95,9 +96,23 @@ void LoftWidget::findShapes()
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();

for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
const TopoDS_Shape& shape = (*it)->Shape.getValue();
TopoDS_Shape shape = (*it)->Shape.getValue();
if (shape.IsNull()) continue;

// also allow compounds with a single face, wire, edge or vertex
if (shape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(shape);
int numChilds=0;
TopoDS_Shape child;
for (; it.More(); it.Next(), numChilds++) {
if (!it.Value().IsNull())
child = it.Value();
}

if (numChilds == 1)
shape = child;
}

if (shape.ShapeType() == TopAbs_FACE ||
shape.ShapeType() == TopAbs_WIRE ||
shape.ShapeType() == TopAbs_EDGE ||
Expand Down
17 changes: 16 additions & 1 deletion src/Mod/Part/Gui/TaskSweep.cpp
Expand Up @@ -29,6 +29,7 @@
# include <QTextStream>
# include <BRepBuilderAPI_MakeWire.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Iterator.hxx>
#endif

#include "ui_TaskSweep.h"
Expand Down Expand Up @@ -118,9 +119,23 @@ void SweepWidget::findShapes()
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();

for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
const TopoDS_Shape& shape = (*it)->Shape.getValue();
TopoDS_Shape shape = (*it)->Shape.getValue();
if (shape.IsNull()) continue;

// also allow compounds with a single face, wire, edge or vertex
if (shape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(shape);
int numChilds=0;
TopoDS_Shape child;
for (; it.More(); it.Next(), numChilds++) {
if (!it.Value().IsNull())
child = it.Value();
}

if (numChilds == 1)
shape = child;
}

if (shape.ShapeType() == TopAbs_FACE ||
shape.ShapeType() == TopAbs_WIRE ||
shape.ShapeType() == TopAbs_EDGE ||
Expand Down

0 comments on commit 318c4b6

Please sign in to comment.