| 126 | } |
| 127 | |
| 128 | App::DocumentObjectExecReturn* RuledSurface::execute() |
| 129 | { |
| 130 | try { |
| 131 | std::vector<TopoShape> shapes; |
| 132 | std::array<App::PropertyLinkSub*, 2> links = {&Curve1, &Curve2}; |
| 133 | for (auto link : links) { |
| 134 | App::DocumentObject* obj = link->getValue(); |
| 135 | const Part::TopoShape part |
| 136 | = Part::Feature::getTopoShape(obj, ShapeOption::ResolveLink | ShapeOption::Transform); |
| 137 | if (part.isNull()) { |
| 138 | return new App::DocumentObjectExecReturn("No shape linked."); |
| 139 | } |
| 140 | // if no explicit sub-shape is selected use the whole part |
| 141 | const auto& subs = link->getSubValues(); |
| 142 | if (subs.empty()) { |
| 143 | shapes.push_back(part); |
| 144 | } |
| 145 | else if (subs.size() != 1) { |
| 146 | return new App::DocumentObjectExecReturn("Not exactly one sub-shape linked."); |
| 147 | } |
| 148 | else { |
| 149 | shapes.push_back(getTopoShape( |
| 150 | link->getValue(), |
| 151 | ShapeOption::NeedSubElement | ShapeOption::ResolveLink | ShapeOption::Transform, |
| 152 | subs.front().c_str() |
| 153 | )); |
| 154 | } |
| 155 | if (shapes.back().isNull()) { |
| 156 | return new App::DocumentObjectExecReturn("Invalid link."); |
| 157 | } |
| 158 | } |
| 159 | TopoShape res(0, getDocument()->getStringHasher()); |
| 160 | res.makeElementRuledSurface(shapes, Orientation.getValue()); |
| 161 | this->Shape.setValue(res); |
| 162 | return Part::Feature::execute(); |
| 163 | } |
| 164 | catch (Standard_Failure& e) { |
| 165 | |
| 166 | return new App::DocumentObjectExecReturn(e.GetMessageString()); |
| 167 | } |
| 168 | catch (...) { |
| 169 | return new App::DocumentObjectExecReturn("General error in RuledSurface::execute()"); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | // ---------------------------------------------------------------------------- |
| 174 |
nothing calls this directly
no test coverage detected