MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / execute

Method execute

src/Mod/PartDesign/App/FeaturePrimitive.cpp:72–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& primitive)
73{
74 if (onlyHaveRefined()) {
75 return App::DocumentObject::StdReturn;
76 }
77
78 try {
79 // transform the primitive in the correct coordinance
80 FeatureAddSub::execute();
81
82 // if we have no base we just add the standard primitive shape
83 TopoShape primitiveShape;
84 primitiveShape.setShape(primitive);
85
86 TopoShape base;
87 try {
88 // if we have a base shape we need to make sure that it does not get our transformation
89 // to
90 base = getBaseTopoShape().moved(getLocation().Inverted());
91 primitiveShape.Tag = -this->getID();
92 }
93
94 catch (const Base::Exception&) {
95
96 // as we use this for preview we can add it even if useless for subtractive
97 AddSubShape.setValue(primitiveShape);
98
99 if (getAddSubType() == FeatureAddSub::Additive) {
100 Shape.setValue(getSolid(primitiveShape));
101 }
102 else {
103 return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP(
104 "Exception",
105 "Cannot subtract primitive feature without base feature"
106 ));
107 }
108
109 return App::DocumentObject::StdReturn;
110 }
111 AddSubShape.setValue(primitiveShape);
112
113 TopoShape boolOp(0);
114
115 const char* maker;
116 switch (getAddSubType()) {
117 case Additive:
118 maker = Part::OpCodes::Fuse;
119 break;
120 case Subtractive:
121 maker = Part::OpCodes::Cut;
122 break;
123 default:
124 return new App::DocumentObjectExecReturn(
125 QT_TRANSLATE_NOOP("Exception", "Unknown operation type")
126 );
127 }
128 try {
129 boolOp.makeElementBoolean(maker, {base, primitiveShape}, nullptr, FuzzyTolerance.getValue());

Callers

nothing calls this directly

Calls 15

absFunction · 0.85
toRadiansFunction · 0.85
movedMethod · 0.80
SetValueMethod · 0.80
rotZMethod · 0.80
WireMethod · 0.80
executeFunction · 0.70
gp_PntClass · 0.70
QT_TRANSLATE_NOOPFunction · 0.50
gp_Ax2Class · 0.50
setShapeMethod · 0.45
getIDMethod · 0.45

Tested by

no test coverage detected