| 1289 | } |
| 1290 | |
| 1291 | static int fillet(Solid* pNewSolid, Solid* pSolid, const std::vector<Edge*>& edges, const std::vector<double>& radius) |
| 1292 | { |
| 1293 | size_t edges_size = edges.size(); |
| 1294 | size_t radius_size = radius.size(); |
| 1295 | |
| 1296 | try { |
| 1297 | BRepFilletAPI_MakeFillet tool(pSolid->shape()); |
| 1298 | |
| 1299 | TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace; |
| 1300 | TopExp::MapShapesAndAncestors(pSolid->shape(), TopAbs_EDGE, TopAbs_FACE, mapEdgeFace); |
| 1301 | |
| 1302 | for (size_t i = 0; i < edges.size(); i++) { |
| 1303 | |
| 1304 | const TopoDS_Edge& edge = edges[i]->edge(); |
| 1305 | |
| 1306 | // skip degenerated edge |
| 1307 | if (BRep_Tool::Degenerated(edge)) |
| 1308 | continue; |
| 1309 | |
| 1310 | const TopoDS_Face& face = TopoDS::Face(mapEdgeFace.FindFromKey(edge).First()); |
| 1311 | |
| 1312 | // skip edge if it is a seam |
| 1313 | if (BRep_Tool::IsClosed(edge, face)) |
| 1314 | continue; |
| 1315 | |
| 1316 | if (radius_size == 1) { |
| 1317 | // single radius |
| 1318 | tool.Add(radius[0], edge); |
| 1319 | } |
| 1320 | else if (radius_size == edges_size) { |
| 1321 | // radius given for each edge |
| 1322 | tool.Add(radius[i], edge); |
| 1323 | } |
| 1324 | else if (radius_size == 2 * edges_size) { |
| 1325 | // variable radius |
| 1326 | tool.Add(radius[2 * i + 0], radius[2 * i + 1], edge); |
| 1327 | } |
| 1328 | else { |
| 1329 | StdFail_NotDone::Raise("radius argument size not valid");; |
| 1330 | } |
| 1331 | } |
| 1332 | |
| 1333 | tool.Build(); |
| 1334 | |
| 1335 | if (!tool.IsDone()) { |
| 1336 | StdFail_NotDone::Raise("Fillet operation has failed"); |
| 1337 | } |
| 1338 | |
| 1339 | const TopoDS_Shape& tmp = tool.Shape(); |
| 1340 | |
| 1341 | if (tmp.IsNull()) { |
| 1342 | StdFail_NotDone::Raise("Fillet operation resulted in Null shape"); |
| 1343 | } |
| 1344 | |
| 1345 | pNewSolid->setShape(tmp); |
| 1346 | |
| 1347 | // possible fix shape |
| 1348 | //xx if (!pNewSolid->fixShape()) { |
no test coverage detected