1
/***************************************************************************
2
* Copyright (c) 2009 Werner Mayer <wmayer[at]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 <gp_Ax1.hxx>
30
#include "FeatureRevolution.h"
35
App::PropertyFloatConstraint::Constraints Revolution::angleRangeU = {0.0f,360.0f,1.0f};
37
PROPERTY_SOURCE(Part::Revolution, Part::Feature)
39
Revolution::Revolution()
41
ADD_PROPERTY(Source,(0));
42
ADD_PROPERTY(Base,(Base::Vector3f(0.0f,0.0f,0.0f)));
43
ADD_PROPERTY(Axis,(Base::Vector3f(0.0f,0.0f,1.0f)));
44
ADD_PROPERTY(Angle,(360.0f));
45
Angle.setConstraints(&angleRangeU);
48
short Revolution::mustExecute() const
50
if (Base.isTouched() ||
57
App::DocumentObjectExecReturn *Revolution::execute(void)
59
App::DocumentObject* link = Source.getValue();
61
return new App::DocumentObjectExecReturn("No object linked");
62
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
63
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
64
Part::Feature *base = static_cast<Part::Feature*>(Source.getValue());
66
Base::Vector3f b = Base.getValue();
67
Base::Vector3f v = Axis.getValue();
68
gp_Pnt pnt(b.x,b.y,b.z);
69
gp_Dir dir(v.x,v.y,v.z);
72
// Now, let's get the TopoDS_Shape
73
TopoDS_Shape revolve = base->Shape.getShape().revolve(gp_Ax1(pnt, dir),
74
Angle.getValue()/180.0f*Standard_PI);
76
return new App::DocumentObjectExecReturn("Resulting shape is null");
77
this->Shape.setValue(revolve);
78
return App::DocumentObject::StdReturn;
80
catch (Standard_Failure) {
81
Handle_Standard_Failure e = Standard_Failure::Caught();
82
return new App::DocumentObjectExecReturn(e->GetMessageString());