forked from FreeCAD/FreeCAD
/
FeatureExtrusion.h
158 lines (138 loc) · 5.93 KB
/
FeatureExtrusion.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef PART_FEATUREEXTRUSION_H
#define PART_FEATUREEXTRUSION_H
#include <App/PropertyStandard.h>
#include <App/PropertyUnits.h>
#include <App/StringHasher.h>
#include "PartFeature.h"
#include "FaceMakerCheese.h"
#include <TopoDS_Face.hxx>
namespace Part
{
class PartExport Extrusion : public Part::Feature
{
PROPERTY_HEADER_WITH_OVERRIDE(Part::Extrusion);
public:
Extrusion();
App::PropertyLink Base;
App::PropertyVector Dir;
App::PropertyEnumeration DirMode;
App::PropertyLinkSub DirLink;
App::PropertyDistance LengthFwd;
App::PropertyDistance LengthRev;
App::PropertyBool Solid;
App::PropertyBool Reversed;
App::PropertyBool Symmetric;
App::PropertyAngle TaperAngle;
App::PropertyAngle TaperAngleRev;
App::PropertyAngle InnerTaperAngle;
App::PropertyAngle InnerTaperAngleRev;
App::PropertyString FaceMakerClass;
App::PropertyBool UsePipeForDraft;
App::PropertyBool Linearize;
/**
* @brief The ExtrusionParameters struct is supposed to be filled with final
* extrusion parameters, after resolving links, applying mode logic,
* reversing, etc., and be passed to extrudeShape.
*/
struct PartExport ExtrusionParameters {
gp_Dir dir;
double lengthFwd;
double lengthRev;
bool solid;
bool innertaper;
bool usepipe;
bool linearize;
double taperAngleFwd; //in radians
double taperAngleRev;
double innerTaperAngleFwd; //in radians
double innerTaperAngleRev;
std::string faceMakerClass;
ExtrusionParameters();
};
/** @name methods override feature */
//@{
/// recalculate the feature
App::DocumentObjectExecReturn *execute(void) override;
short mustExecute() const override;
/// returns the type name of the view provider
const char* getViewProviderName(void) const override {
return "PartGui::ViewProviderExtrusion";
}
//@}
/**
* @brief extrudeShape powers the extrusion feature.
* @param source: the shape to be extruded
* @param params: extrusion parameters
* @return result of extrusion
*/
static void extrudeShape(TopoShape &result, const TopoShape &source, const ExtrusionParameters& params);
/**
* @brief fetchAxisLink: read AxisLink to obtain the direction and
* length. Note: this routine is re-used in Extrude dialog, hence it
* is static.
* @param axisLink (input): the link
* @param basepoint (output): starting point of edge. Not used by extrude as of now.
* @param dir (output): direction of axis, with magnitude (length)
* @return true if link was fetched. false if link was empty. Throws if the
* link is wrong.
*/
static bool fetchAxisLink(const App::PropertyLinkSub& axisLink,
Base::Vector3d &basepoint,
Base::Vector3d &dir);
/**
* @brief computeFinalParameters: applies mode logic and fetches links, to
* compute the actual parameters of extrusion. Dir property is updated in
* the process, hence the function is non-const.
*/
ExtrusionParameters computeFinalParameters();
static Base::Vector3d calculateShapeNormal(const App::PropertyLink &shapeLink);
public: //mode enumerations
enum eDirMode{
dmCustom,
dmEdge,
dmNormal
};
static const char* eDirModeStrings[];
static void makeDraft(const ExtrusionParameters& params, const TopoShape&,
std::vector<TopoShape>&, App::StringHasherRef hasher);
protected:
virtual void setupObject() override;
};
/**
* @brief FaceMakerExtrusion provides legacy compounding-structure-ignorant behavior of facemaker of Part Extrude.
* Strengths: makes faces with holes
* Weaknesses: can't make islands in holes. Ignores compounding nesting. All faces must be on same plane.
*/
class FaceMakerExtrusion: public FaceMakerCheese
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
virtual std::string getUserFriendlyName() const override;
virtual std::string getBriefExplanation() const override;
virtual void Build() override;
protected:
virtual void Build_Essence() override {}
};
} //namespace Part
#endif // PART_FEATUREEXTRUSION_H