1
/***************************************************************************
2
* Copyright (c) 2008 Werner Mayer <wmayer@users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
24
#include "PreCompiled.h"
26
# include <BRepFilletAPI_MakeFillet.hxx>
27
# include <TopExp_Explorer.hxx>
28
# include <TopoDS.hxx>
29
# include <TopoDS_Edge.hxx>
33
#include "FeatureFillet.h"
36
using namespace PartDesign;
39
PROPERTY_SOURCE(PartDesign::Fillet, Part::Feature)
43
ADD_PROPERTY(Base,(0));
44
ADD_PROPERTY(Contour,(0,0,0));
48
short Fillet::mustExecute() const
50
if (Base.isTouched() || Contour.isTouched())
55
App::DocumentObjectExecReturn *Fillet::execute(void)
57
App::DocumentObject* link = Base.getValue();
59
return new App::DocumentObjectExecReturn("No object linked");
60
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
61
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
62
Part::Feature *base = static_cast<Part::Feature*>(Base.getValue());
66
BRepFilletAPI_MakeFillet mkFillet(base->Shape.getValue());
67
TopExp_Explorer xp(base->Shape.getValue(), TopAbs_EDGE);
69
//std::map<int, TopoDS_Edge> edgeMap;
70
for (;xp.More();xp.Next()) {
71
TopoDS_Edge edge = TopoDS::Edge(xp.Current());
72
mkFillet.Add(radius, radius, edge);
73
//edgeMap[edge.HashCode(IntegerLast())] = edge;
76
std::vector<FilletElement> values = Contour.getValues();
77
for (std::vector<FilletElement>::iterator it = values.begin(); it != values.end(); ++it) {
79
double radius1 = it->radius1;
80
double radius2 = it->radius2;
81
std::map<int, TopoDS_Edge>::iterator ed = edgeMap.find(id);
82
if (ed != edgeMap.end())
83
mkFillet.Add(radius1, radius2, ed->second);
87
TopoDS_Shape shape = mkFillet.Shape();
89
return new App::DocumentObjectExecReturn("Resulting shape is null");
90
this->Shape.setValue(shape);
91
return App::DocumentObject::StdReturn;
93
catch (Standard_Failure) {
94
Handle_Standard_Failure e = Standard_Failure::Caught();
95
return new App::DocumentObjectExecReturn(e->GetMessageString());