From e28428672841382aeeb29d0f4a9ee256f3175da4 Mon Sep 17 00:00:00 2001 From: Michael Hoffer Date: Tue, 29 Oct 2019 13:26:25 +0100 Subject: [PATCH] chamfer-edges partly works (still buggy, but works in simple cases) --- src/occ-csg.cpp | 73 ++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/src/occ-csg.cpp b/src/occ-csg.cpp index e380459..3a3125d 100644 --- a/src/occ-csg.cpp +++ b/src/occ-csg.cpp @@ -1369,46 +1369,43 @@ void roundEdges(int argc, char* argv[]) { void chamferEdges(int argc, char* argv[]) { - std::cout << "WARNING: this method might not work properly. We need to test newer OCC versions." << std::endl; + std::cout << "WARNING: this method might not work properly. More testing is necessary." << std::endl; - notImplemented(); + if(argc != 6 && argc != 7) { + error("wrong number of arguments!"); + } -// if(argc != 6 && argc != 7) { -// error("wrong number of arguments!"); -// } -// -// double radius = parseDouble(argv[3], "radius"); -// -// std::string fileName = argv[4]; -// std::string outFileName = toLower(argv[5]); -// -// TopoDS_Shape shape = load(fileName); -// -// BRepFilletAPI_MakeChamfer chamfers(shape); -// -// TopTools_IndexedDataMapOfShapeListOfShape M; -// TopExp::MapShapesAndAncestors(shape,TopAbs_EDGE,TopAbs_FACE,M); -// -// for (Standard_Integer i = 1; i < M.Extent(); i++ ) -// { -// TopoDS_Edge E = TopoDS::Edge(TopoDS::Edge(M.FindKey(i))); -// // TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First()); -// TopoDS_Face F = TopoDS::Face(M.FindFromKey(E).First()); -// chamfers.Add(radius,E,F); -// } -// -// // create chamfers -// TopoDS_Shape shapeOut= chamfers.Shape(); -// -// double stlTOL; -// -// if(argc == 7) { -// stlTOL = parseDouble(argv[6], "stlTOL"); -// } else { -// stlTOL = 0.5; -// } -// -// save(outFileName, shapeOut, stlTOL); + double radius = parseDouble(argv[3], "radius"); + + std::string fileName = argv[4]; + std::string outFileName = toLower(argv[5]); + + TopoDS_Shape shape = load(fileName); + + BRepFilletAPI_MakeChamfer chamfers(shape); + + TopTools_IndexedDataMapOfShapeListOfShape M; + TopExp::MapShapesAndAncestors(shape,TopAbs_EDGE,TopAbs_FACE,M); + + for (Standard_Integer i = 1; i <= M.Extent(); i++ ) + { + TopoDS_Edge E = TopoDS::Edge(TopoDS::Edge(M.FindKey(i))); + TopoDS_Face F = TopoDS::Face(M.FindFromKey(E).First()); + chamfers.Add(radius,radius,E,F); + } + + // create chamfers + TopoDS_Shape shapeOut= chamfers.Shape(); + + double stlTOL; + + if(argc == 7) { + stlTOL = parseDouble(argv[6], "stlTOL"); + } else { + stlTOL = 0.5; + } + + save(outFileName, shapeOut, stlTOL); } TopoDS_Shape createBox(double x1, double y1, double z1, double x2, double y2, double z2) {