Toposhape/Part: clean, add tests for makeElementFillet and makeElementChamfer

This commit is contained in:
bgbsww
2024-02-21 15:18:11 -05:00
parent 952ae46d49
commit 1470616abe
3 changed files with 356 additions and 60 deletions

View File

@@ -49,6 +49,8 @@
#include <BRepAlgoAPI_Section.hxx>
#include <BRepBuilderAPI_Copy.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepFilletAPI_MakeChamfer.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#include <BRepLib.hxx>
#include <BRepOffsetAPI_DraftAngle.hxx>
#include <BRepOffsetAPI_MakePipe.hxx>
@@ -2143,11 +2145,11 @@ TopoShape& TopoShape::makeElementThickSolid(const TopoShape& shape,
// we do not offer tangent join type
switch (join) {
case JoinType::Arc:
case JoinType::Intersection:
case JoinType::arc:
case JoinType::intersection:
break;
default:
join = JoinType::Intersection;
join = JoinType::intersection;
}
if (shape.isNull()) {
@@ -2594,57 +2596,78 @@ struct MapperThruSections: MapperMaker
}
};
TopoShape &TopoShape::makEFillet(const TopoShape &shape, const std::vector<TopoShape> &edges,
double radius1, double radius2, const char *op)
TopoShape& TopoShape::makeElementFillet(const TopoShape& shape,
const std::vector<TopoShape>& edges,
double radius1,
double radius2,
const char* op)
{
if(!op) op = Part::OpCodes::Fillet;
if(shape.isNull())
HANDLE_NULL_SHAPE;
if(edges.empty())
HANDLE_NULL_INPUT;
if (!op) {
op = Part::OpCodes::Fillet;
}
if (shape.isNull()) {
FC_THROWM(NullShapeException, "Null shape");
}
if (edges.empty()) {
FC_THROWM(NullShapeException, "Null input shape");
}
BRepFilletAPI_MakeFillet mkFillet(shape.getShape());
for(auto &e : edges) {
if(e.isNull())
HANDLE_NULL_INPUT;
const auto &edge = e.getShape();
if(!shape.findShape(edge))
FC_THROWM(Base::CADKernelError,"edge does not belong to the shape");
for (auto& e : edges) {
if (e.isNull()) {
FC_THROWM(NullShapeException, "Null input shape");
}
const auto& edge = e.getShape();
if (!shape.findShape(edge)) {
FC_THROWM(Base::CADKernelError, "edge does not belong to the shape");
}
mkFillet.Add(radius1, radius2, TopoDS::Edge(edge));
}
return makEShape(mkFillet,shape,op);
return makeElementShape(mkFillet, shape, op);
}
TopoShape &TopoShape::makEChamfer(const TopoShape &shape, const std::vector<TopoShape> &edges,
double radius1, double radius2, const char *op, bool flipDirection, bool asAngle)
TopoShape& TopoShape::makeElementChamfer(const TopoShape& shape,
const std::vector<TopoShape>& edges,
double radius1,
double radius2,
const char* op,
Flip flipDirection,
AsAngle asAngle)
{
if(!op) op = Part::OpCodes::Chamfer;
if(shape.isNull())
HANDLE_NULL_SHAPE;
if(edges.empty())
HANDLE_NULL_INPUT;
BRepFilletAPI_MakeChamfer mkChamfer(shape.getShape());
for(auto &e : edges) {
const auto &edge = e.getShape();
if(e.isNull())
HANDLE_NULL_INPUT;
if(!shape.findShape(edge))
FC_THROWM(Base::CADKernelError,"edge does not belong to the shape");
//Add edge to fillet algorithm
TopoDS_Shape face;
if(flipDirection)
face = shape.findAncestorsShapes(edge,TopAbs_FACE).back();
else
face = shape.findAncestorShape(edge,TopAbs_FACE);
if(asAngle)
mkChamfer.AddDA(radius1, radius2, TopoDS::Edge(edge), TopoDS::Face(face));
else
mkChamfer.Add(radius1, radius2, TopoDS::Edge(edge), TopoDS::Face(face));
if (!op) {
op = Part::OpCodes::Chamfer;
}
return makEShape(mkChamfer,shape,op);
if (shape.isNull()) {
FC_THROWM(NullShapeException, "Null shape");
}
if (edges.empty()) {
FC_THROWM(NullShapeException, "Null input shape");
}
BRepFilletAPI_MakeChamfer mkChamfer(shape.getShape());
for (auto& e : edges) {
const auto& edge = e.getShape();
if (e.isNull()) {
FC_THROWM(NullShapeException, "Null input shape");
}
if (!shape.findShape(edge)) {
FC_THROWM(Base::CADKernelError, "edge does not belong to the shape");
}
// Add edge to fillet algorithm
TopoDS_Shape face;
if (flipDirection == Flip::flip) {
face = shape.findAncestorsShapes(edge, TopAbs_FACE).back();
}
else {
face = shape.findAncestorShape(edge, TopAbs_FACE);
}
if (asAngle == AsAngle::yes) {
mkChamfer.AddDA(radius1, radius2, TopoDS::Edge(edge), TopoDS::Face(face));
}
else {
mkChamfer.Add(radius1, radius2, TopoDS::Edge(edge), TopoDS::Face(face));
}
}
return makeElementShape(mkChamfer, shape, op);
}
TopoShape& TopoShape::makeElementGeneralFuse(const std::vector<TopoShape>& _shapes,