tpaviot / oce

OpenCASCADE Community Edition (OCE): a community driven fork of the Open CASCADE library.
http://groups.google.com/group/oce-dev
GNU Lesser General Public License v2.1
808 stars 284 forks source link

BRepOffsetAPI_MakePipeShell 构建放样实体存在问题 #743

Closed MonoKelvin closed 2 years ago

MonoKelvin commented 3 years ago

放样存在问题:

TopoDS_Wire BuildPath()
{
    const double dRadius = 5;
    const double dStartAngle = 0;
    const double dEndAngle = M_PI;
    const gp_Pnt center(0, 0, 0);

    // 直线
    const gp_Pnt p1 = center.XYZ();
    const gp_Pnt p2 = center.XYZ() + gp_XYZ(dRadius, 0, 0);
    const TopoDS_Edge lineEdge = BRepBuilderAPI_MakeEdge(p1, p2);

    // 圆弧
    const gp_Dir zDir(0., 0., 1.);
    const gp_Dir xDir(1., 0., 0.);
    const gp_Ax2 axis(center, zDir, xDir);
    const gp_Circ circ(axis, dRadius);
    Handle(Geom_Circle) C = new Geom_Circle(circ);
    Handle(Geom_TrimmedCurve) arc = new Geom_TrimmedCurve(C, dStartAngle, dEndAngle);
    const TopoDS_Edge arcEdge = BRepBuilderAPI_MakeEdge(arc);

    BRepBuilderAPI_MakeWire mw;
    mw.Add(lineEdge);
    mw.Add(arcEdge);
    return mw.Wire();
}

TopoDS_Wire BuildProfile()
{
    const double dRadius = 1;
    const gp_Pnt center(0, 0, 0);
    const gp_Dir zDir(1., 0., 0.);
    const gp_Dir xDir(0., -1., 0.);
    const gp_Ax2 axis(center, zDir, xDir);
    const gp_Circ circ(axis, dRadius);
    const TopoDS_Edge arcEdge = BRepBuilderAPI_MakeEdge(circ);
    return BRepBuilderAPI_MakeWire(arcEdge);
}

void Test1()
{
    try 
    {
        TopoDS_Shape path, profile, result;

        path = BuildPath();
        profile = BuildProfile();

        TopoDS_Wire aPathWire = TopoDS::Wire(path);
        TopoDS_Wire aProfileWire = TopoDS::Wire(profile);

        BRepOffsetAPI_MakePipeShell mps(aPathWire);
        mps.Add(aProfileWire);
        mps.SetTransitionMode(BRepBuilderAPI_RightCorner);
        mps.Build();

        result = mps.Shape();
    }
    catch (...)
    {
    }
}

我向上面这样构建一个由直线和圆弧组合的路径以及圆形轮廓,使用BRepOffsetAPI_MakePipeShell放样时结果出错。我调试过源码,发现是在IntPatch_ImpPrmIntersection求取实体交线时得到的交线有错误。

MonoKelvin commented 2 years ago

我后来又测试过了,交线没有错误但对于该算法应该要“打断”,否则在BRepFill_TrimShellCorner::MakeFacesSec方法中筛选不到正确的截面轮廓线。

ShenWang6688 commented 2 weeks ago

我也遇到了这个问题,尝试用了三种方式进行扫掠,结果都不太令人满意,想问下您这部分是怎么解决的呢 Snipaste_2024-07-10_10-40-03 Snipaste_2024-07-10_10-40-36