jianbaoxia
CAD master
Hi Bros, I'm jianbaoxia.
Today, I get a plane, and it's bound is a bspline curve, I try to fill the plane with tool path.
So I try to offset the bound edge, and I write a demo to fill a plane with BRepOffsetAPI_MakeOffset , it works, as show:
However, the same way doesn't work for bspline bound, as show below:
So is the BRepOffsetAPI_MakeOffset class don't design for bspline curve?
At last, give my demo:
Today, I get a plane, and it's bound is a bspline curve, I try to fill the plane with tool path.
So I try to offset the bound edge, and I write a demo to fill a plane with BRepOffsetAPI_MakeOffset , it works, as show:
However, the same way doesn't work for bspline bound, as show below:
So is the BRepOffsetAPI_MakeOffset class don't design for bspline curve?
At last, give my demo:
Code:
bool WriteStepFile(const TopoDS_Shape& shape, const std::string filepath)
{
bool output_flag = true;
STEPControl_Writer writer;
Interface_Static::SetCVal("write.step.schema", "AP203");
IFSelect_ReturnStatus status = writer.Transfer(shape, STEPControl_AsIs);
if (status != IFSelect_RetDone) output_flag = false;
status = writer.Write(filepath.c_str());
if (status != IFSelect_RetDone) output_flag = false;
return output_flag;
}
void Demo_offsetCircle()
{
gp_Circ cir(gp::XOY(), 6);
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(cir);
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edge);
TopoDS_Face face = BRepBuilderAPI_MakeFace(wire);
//!2、 make offset
BRepOffsetAPI_MakeOffset offseter(face);
offseter.AddWire(wire);
BRepBuilderAPI_Sewing aSewMaker;
for (int i = 1; i <= 30; i++)
{
offseter.Perform(-0.2 * i);
if (offseter.IsDone())
aSewMaker.Add(offseter.Shape());
}
aSewMaker.Add(face);
aSewMaker.Perform();
TopoDS_Shape offsetShape = aSewMaker.SewedShape();
WriteStepFile(offsetShape, "../offsetShape.step");
}
int main()
{
Demo_offsetCircle();
TopoDS_Shape aShape = ReadStepFile("../aFace.step");
TopoChecker(aShape);
TopoDS_Face aFace;
for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next())
aFace = TopoDS::Face(exp.Current());
TopoDS_Wire aWire;
for (TopExp_Explorer exp(aShape, TopAbs_WIRE); exp.More(); exp.Next())
aWire = TopoDS::Wire(exp.Current());
TopoDS_Edge aEdge;
for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next())
aEdge = TopoDS::Edge(exp.Current());
//!
BRepOffsetAPI_MakeOffset offseter(aFace);
offseter.AddWire(aWire);
BRepBuilderAPI_Sewing aSewMaker;
for (int i = 0; i <= 5; i++)
{
offseter.Perform(-0.1 * i);
if (offseter.IsDone())
aSewMaker.Add(offseter.Shape());
}
aSewMaker.Perform();
TopoDS_Shape offsetShape = aSewMaker.SewedShape();
WriteStepFile(offsetShape, "../offsetShape.step");
}