PartDesign: Implement preview for Draft
This commit is contained in:
committed by
Chris Hennes
parent
667990ec7b
commit
bdba939f9f
@@ -43,6 +43,7 @@
|
||||
#endif
|
||||
|
||||
#include <App/Datums.h>
|
||||
#include <App/Document.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Tools.h>
|
||||
@@ -276,49 +277,16 @@ App::DocumentObjectExecReturn *Draft::execute()
|
||||
Part::TopoShape baseShape(TopShape);
|
||||
baseShape.setTransform(Base::Matrix4D());
|
||||
try {
|
||||
BRepOffsetAPI_DraftAngle mkDraft;
|
||||
// Note:
|
||||
// LocOpe_SplitDrafts can split a face with a wire and apply draft to both parts
|
||||
// Not clear though whether the face must have free boundaries
|
||||
// LocOpe_DPrism can create a stand-alone draft prism. The sketch can only have a single
|
||||
// wire, though.
|
||||
// BRepFeat_MakeDPrism requires a support for the operation but will probably support multiple
|
||||
// wires in the sketch
|
||||
std::vector<TopoShape> faces = getFaces(baseShape);
|
||||
|
||||
bool success;
|
||||
TopoShape shape({}, getDocument()->getStringHasher());
|
||||
shape.makeElementDraft(baseShape, faces, pullDirection, angle, neutralPlane, reversed);
|
||||
|
||||
do {
|
||||
success = true;
|
||||
mkDraft.Init(baseShape.getShape());
|
||||
|
||||
for (std::vector<std::string>::iterator it=SubVals.begin(); it != SubVals.end(); ++it) {
|
||||
TopoDS_Face face = TopoDS::Face(baseShape.getSubShape(it->c_str()));
|
||||
// TODO: What is the flag for?
|
||||
mkDraft.Add(face, pullDirection, angle, neutralPlane);
|
||||
if (!mkDraft.AddDone()) {
|
||||
// Note: the function ProblematicShape returns the face on which the error occurred
|
||||
// Note: mkDraft.Remove() stumbles on a bug in Draft_Modification::Remove() and is
|
||||
// therefore unusable. See https://forum.freecad.org/viewtopic.php?f=10&t=3209&start=10#p25341
|
||||
// The only solution is to discard mkDraft and start over without the current face
|
||||
// mkDraft.Remove(face);
|
||||
Base::Console().error("Adding face failed on %s. Omitted\n", it->c_str());
|
||||
success = false;
|
||||
SubVals.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!success);
|
||||
|
||||
mkDraft.Build();
|
||||
if (!mkDraft.IsDone())
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Failed to create draft"));
|
||||
|
||||
TopoDS_Shape shape = mkDraft.Shape();
|
||||
if (shape.IsNull())
|
||||
if (shape.isNull()) {
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Resulting shape is null"));
|
||||
}
|
||||
|
||||
if (!isSingleSolidRuleSatisfied(shape)) {
|
||||
if (!isSingleSolidRuleSatisfied(shape.getShape())) {
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: that is not currently supported."));
|
||||
}
|
||||
|
||||
|
||||
@@ -301,6 +301,7 @@ TaskDlgDraftParameters::TaskDlgDraftParameters(ViewProviderDraft* DressUpView)
|
||||
parameter = new TaskDraftParameters(DressUpView);
|
||||
|
||||
Content.push_back(parameter);
|
||||
Content.push_back(preview);
|
||||
}
|
||||
|
||||
TaskDlgDraftParameters::~TaskDlgDraftParameters() = default;
|
||||
|
||||
Reference in New Issue
Block a user