Toposhape/Part: Transfer in makEFillet and makEChamfer

This commit is contained in:
Zheng, Lei
2024-02-21 15:04:15 -05:00
committed by bgbsww
parent 81d07d833d
commit 952ae46d49
2 changed files with 118 additions and 0 deletions

View File

@@ -1317,6 +1317,71 @@ public:
{
return TopoShape(0, Hasher).makeElementBoolean(maker, *this, op, tol);
}
/* Make fillet shape
*
* @param source: the source shape
* @param edges: the edges of the source shape where to make fillets
* @param radius1: the radius of the beginning of the fillet
* @param radius2: the radius of the ending of the fillet
* @param op: optional string to be encoded into topo naming for indicating
* the operation
*
* @return The original content of this TopoShape is discarded and replaced
* with the new shape. The function returns the TopoShape itself as
* a self reference so that multiple operations can be carried out
* for the same shape in the same line of code.
*/
TopoShape &makEFillet(const TopoShape &source, const std::vector<TopoShape> &edges,
double radius1, double radius2, const char *op=nullptr);
/* Make fillet shape
*
* @param source: the source shape
* @param edges: the edges of the source shape where to make fillets
* @param radius1: the radius of the beginning of the fillet
* @param radius2: the radius of the ending of the fillet
* @param op: optional string to be encoded into topo naming for indicating
* the operation
*
* @return Return the new shape. The TopoShape itself is not modified.
*/
TopoShape makEFillet(const std::vector<TopoShape> &edges,
double radius1, double radius2, const char *op=nullptr) const {
return TopoShape(0,Hasher).makEFillet(*this,edges,radius1,radius2,op);
}
/* Make chamfer shape
*
* @param source: the source shape
* @param edges: the edges of the source shape where to make chamfers
* @param radius1: the radius of the beginning of the chamfer
* @param radius2: the radius of the ending of the chamfer
* @param op: optional string to be encoded into topo naming for indicating
* the operation
*
* @return The original content of this TopoShape is discarded and replaced
* with the new shape. The function returns the TopoShape itself as
* a self reference so that multiple operations can be carried out
* for the same shape in the same line of code.
*/
TopoShape &makEChamfer(const TopoShape &source, const std::vector<TopoShape> &edges,
double radius1, double radius2, const char *op=nullptr, bool flipDirection=false, bool asAngle=false);
/* Make chamfer shape
*
* @param source: the source shape
* @param edges: the edges of the source shape where to make chamfers
* @param radius1: the radius of the beginning of the chamfer
* @param radius2: the radius of the ending of the chamfer
* @param op: optional string to be encoded into topo naming for indicating
* the operation
*
* @return Return the new shape. The TopoShape itself is not modified.
*/
TopoShape makEChamfer(const std::vector<TopoShape> &edges,
double radius1, double radius2, const char *op=nullptr, bool flipDirection=false, bool asAngle=false) const {
return TopoShape(0,Hasher).makEChamfer(*this,edges,radius1,radius2,op,flipDirection,asAngle);
}
/* Make draft shape
*
* @param source: the source shape

View File

@@ -2594,6 +2594,59 @@ struct MapperThruSections: MapperMaker
}
};
TopoShape &TopoShape::makEFillet(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;
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");
mkFillet.Add(radius1, radius2, TopoDS::Edge(edge));
}
return makEShape(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)
{
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));
}
return makEShape(mkChamfer,shape,op);
}
TopoShape& TopoShape::makeElementGeneralFuse(const std::vector<TopoShape>& _shapes,
std::vector<std::vector<TopoShape>>& modifies,
double tol,