Skip to content

Commit

Permalink
chamfer-edges partly works (still buggy, but works in simple cases)
Browse files Browse the repository at this point in the history
  • Loading branch information
miho committed Oct 29, 2019
1 parent 72e81f9 commit e284286
Showing 1 changed file with 35 additions and 38 deletions.
73 changes: 35 additions & 38 deletions src/occ-csg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e284286

Please sign in to comment.