+ fixes #0001547: add Part Spiral to the selectable list of profiles for a Part Loft
This commit is contained in:
parent
f9ff3b250e
commit
318c4b6ce9
|
@ -35,6 +35,7 @@
|
||||||
# include <BRepOffsetAPI_MakePipeShell.hxx>
|
# include <BRepOffsetAPI_MakePipeShell.hxx>
|
||||||
# include <ShapeAnalysis.hxx>
|
# include <ShapeAnalysis.hxx>
|
||||||
# include <TopTools_ListIteratorOfListOfShape.hxx>
|
# include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
# include <TopoDS_Iterator.hxx>
|
||||||
# include <TopExp_Explorer.hxx>
|
# include <TopExp_Explorer.hxx>
|
||||||
# include <TopoDS.hxx>
|
# include <TopoDS.hxx>
|
||||||
# include <Precision.hxx>
|
# include <Precision.hxx>
|
||||||
|
@ -240,9 +241,20 @@ App::DocumentObjectExecReturn *Loft::execute(void)
|
||||||
for (it = shapes.begin(); it != shapes.end(); ++it) {
|
for (it = shapes.begin(); it != shapes.end(); ++it) {
|
||||||
if (!(*it)->isDerivedFrom(Part::Feature::getClassTypeId()))
|
if (!(*it)->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||||
return new App::DocumentObjectExecReturn("Linked object is not a shape.");
|
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())
|
if (shape.IsNull())
|
||||||
return new App::DocumentObjectExecReturn("Linked shape is invalid.");
|
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) {
|
if (shape.ShapeType() == TopAbs_FACE) {
|
||||||
TopoDS_Wire faceouterWire = ShapeAnalysis::OuterWire(TopoDS::Face(shape));
|
TopoDS_Wire faceouterWire = ShapeAnalysis::OuterWire(TopoDS::Face(shape));
|
||||||
profiles.Append(faceouterWire);
|
profiles.Append(faceouterWire);
|
||||||
|
@ -355,9 +367,20 @@ App::DocumentObjectExecReturn *Sweep::execute(void)
|
||||||
for (it = shapes.begin(); it != shapes.end(); ++it) {
|
for (it = shapes.begin(); it != shapes.end(); ++it) {
|
||||||
if (!(*it)->isDerivedFrom(Part::Feature::getClassTypeId()))
|
if (!(*it)->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||||
return new App::DocumentObjectExecReturn("Linked object is not a shape.");
|
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())
|
if (shape.IsNull())
|
||||||
return new App::DocumentObjectExecReturn("Linked shape is invalid.");
|
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.
|
// 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.
|
// If we re-create the wire then everything works fine.
|
||||||
// http://forum.freecadweb.org/viewtopic.php?f=10&t=2673&sid=fbcd2ff4589f0b2f79ed899b0b990648#p20268
|
// http://forum.freecadweb.org/viewtopic.php?f=10&t=2673&sid=fbcd2ff4589f0b2f79ed899b0b990648#p20268
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#ifndef _PreComp_
|
#ifndef _PreComp_
|
||||||
# include <QMessageBox>
|
# include <QMessageBox>
|
||||||
# include <QTextStream>
|
# include <QTextStream>
|
||||||
|
# include <TopoDS_Iterator.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ui_TaskLoft.h"
|
#include "ui_TaskLoft.h"
|
||||||
|
@ -95,9 +96,23 @@ void LoftWidget::findShapes()
|
||||||
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();
|
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();
|
||||||
|
|
||||||
for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
|
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;
|
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 ||
|
if (shape.ShapeType() == TopAbs_FACE ||
|
||||||
shape.ShapeType() == TopAbs_WIRE ||
|
shape.ShapeType() == TopAbs_WIRE ||
|
||||||
shape.ShapeType() == TopAbs_EDGE ||
|
shape.ShapeType() == TopAbs_EDGE ||
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
# include <QTextStream>
|
# include <QTextStream>
|
||||||
# include <BRepBuilderAPI_MakeWire.hxx>
|
# include <BRepBuilderAPI_MakeWire.hxx>
|
||||||
# include <TopoDS.hxx>
|
# include <TopoDS.hxx>
|
||||||
|
# include <TopoDS_Iterator.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ui_TaskSweep.h"
|
#include "ui_TaskSweep.h"
|
||||||
|
@ -118,9 +119,23 @@ void SweepWidget::findShapes()
|
||||||
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();
|
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();
|
||||||
|
|
||||||
for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
|
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;
|
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 ||
|
if (shape.ShapeType() == TopAbs_FACE ||
|
||||||
shape.ShapeType() == TopAbs_WIRE ||
|
shape.ShapeType() == TopAbs_WIRE ||
|
||||||
shape.ShapeType() == TopAbs_EDGE ||
|
shape.ShapeType() == TopAbs_EDGE ||
|
||||||
|
|
Loading…
Reference in New Issue
Block a user