23
#include "PreCompiled.h"
25
# include <BRepFilletAPI_MakeChamfer.hxx>
26
# include <Precision.hxx>
29
# include <TopoDS_Edge.hxx>
30
# include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
31
# include <TopTools_IndexedMapOfShape.hxx>
34
#include "FeatureChamfer.h"
35
#include "TopoShapeOpCode.h"
40
PROPERTY_SOURCE(Part::Chamfer, Part::FilletBase)
42
Chamfer::Chamfer() = default;
44
App::DocumentObjectExecReturn *Chamfer::execute()
46
App::DocumentObject* link = Base.getValue();
48
return new App::DocumentObjectExecReturn("No object linked");
51
TopoShape baseTopoShape = Feature::getTopoShape(link);
52
auto baseShape = Feature::getShape(link);
53
BRepFilletAPI_MakeChamfer mkChamfer(baseShape);
54
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
55
TopExp::MapShapesAndAncestors(baseShape, TopAbs_EDGE, TopAbs_FACE, mapEdgeFace);
56
TopTools_IndexedMapOfShape mapOfEdges;
57
TopExp::MapShapes(baseShape, TopAbs_EDGE, mapOfEdges);
59
const auto &vals = EdgeLinks.getSubValues();
60
const auto &subs = EdgeLinks.getShadowSubs();
61
if(subs.size()!=(size_t)Edges.getSize())
62
return new App::DocumentObjectExecReturn("Edge link size mismatch");
64
for(const auto &info : Edges.getValues()) {
66
auto &ref = sub.newName.size()?sub.newName:vals[i];
73
auto id = Data::MappedName(ref.c_str()).toIndexedName().getIndex();
74
const TopoDS_Edge& edge = TopoDS::Edge(mapOfEdges.FindKey(id));
76
return new App::DocumentObjectExecReturn("Invalid edge link");
77
double radius1 = info.radius1;
78
double radius2 = info.radius2;
79
const TopoDS_Face& face = TopoDS::Face(mapEdgeFace.FindFromKey(edge).First());
80
mkChamfer.Add(radius1, radius2, TopoDS::Edge(edge), face);
83
TopoDS_Shape shape = mkChamfer.Shape();
85
return new App::DocumentObjectExecReturn("Resulting shape is null");
88
this->Shape.setValue(res.makeElementShape(mkChamfer,baseTopoShape,Part::OpCodes::Chamfer));
89
return Part::Feature::execute();
91
catch (Standard_Failure& e) {
92
return new App::DocumentObjectExecReturn(e.GetMessageString());