MCPcopy Create free account
hub / github.com/OpenWebCAD/node-occ / chamfer

Function chamfer

src/ShapeFactory.cc:1218–1289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1216
1217
1218static int chamfer(Solid* pNewSolid, Solid* pSolid, const std::vector<Edge*>& edges, const std::vector<double>& distances)
1219{
1220
1221 size_t edges_size = edges.size();
1222 size_t distances_size = distances.size();
1223
1224 try {
1225 BRepFilletAPI_MakeChamfer CF(pSolid->shape());
1226
1227 TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
1228 TopExp::MapShapesAndAncestors(pSolid->shape(), TopAbs_EDGE, TopAbs_FACE, mapEdgeFace);
1229
1230 for (size_t i = 0; i < edges.size(); i++) {
1231
1232
1233 const TopoDS_Edge& edge = edges[i]->edge();
1234
1235 // skip degenerated edge
1236 if (BRep_Tool::Degenerated(edge))
1237 continue;
1238
1239 const TopoDS_Face& face = TopoDS::Face(mapEdgeFace.FindFromKey(edge).First());
1240
1241 // skip edge if it is a seam
1242 if (BRep_Tool::IsClosed(edge, face))
1243 continue;
1244
1245
1246 if (distances_size == 1) {
1247 // single distance
1248#if (OCC_VERSION_MAJOR ==7 && OCC_VERSION_MINOR <=3)
1249 CF.Add(distances[0], edge, face);
1250#else
1251 CF.Add(edge);
1252#endif
1253
1254 }
1255 else if (distances_size == edges_size) {
1256 // distance given for each edge
1257#if (OCC_VERSION_MAJOR ==7 && OCC_VERSION_MINOR <=3)
1258 CF.Add(distances[i], edge, face);
1259#else
1260 CF.Add(edge);
1261#endif
1262
1263 }
1264 else {
1265 StdFail_NotDone::Raise("size of distances argument not correct");;
1266 }
1267 }
1268
1269 CF.Build();
1270
1271 if (!CF.IsDone())
1272 StdFail_NotDone::Raise("Failed to chamfer solid");
1273
1274 const TopoDS_Shape& tmp = CF.Shape();
1275

Callers

nothing calls this directly

Calls 4

ShapeMethod · 0.80
FaceClass · 0.70
setShapeMethod · 0.45
fixShapeMethod · 0.45

Tested by

no test coverage detected