| 70 | } |
| 71 | |
| 72 | App::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()); |
nothing calls this directly
no test coverage detected