occt7.1 beta 's fillet method is not as good as occt7.0

as the picture show

 

Attachments: 
Forum supervisor's picture

Dear Kate,

Please provide more information on how to reproduce the problem.
If you can, provide DRAW script; at least, provide the shapes (before and after fillet) produced with OCCT 7.0 and 7.1, and describe how fillet has been applied.

Best Regards, FSR

Kate Ken's picture

Dear admin, thanks for you reply!,below is the code which can be directly compiled with 7.0.0 and 7.1.0beta, it results a final stl.you can check this

gp_Pnt JiZhunXian2_v0 = gp_Pnt(-17.6, 0.0, 0.0);
    gp_Pnt JiZhunXian2_v1 = gp_Pnt(0, 32.8, 0.0);

    gp_Pnt curve_bz0_v0 = JiZhunXian2_v0;
    gp_Pnt curve_bz0_v3 = JiZhunXian2_v1;
    float ratio1 = 5.4 / 13.2;
    gp_Pnt curve_bz0_v1 = gp_Pnt(curve_bz0_v0.X(), ratio1*curve_bz0_v3.Y(), 0);
    float ratio2 = 6.0 / 6.8;
    gp_Pnt curve_bz0_v2 = gp_Pnt(ratio2*curve_bz0_v0.X(), curve_bz0_v3.Y(), 0);

    TColgp_Array1OfPnt poles(1, 4);
    poles.SetValue(1, curve_bz0_v0);
    poles.SetValue(2, curve_bz0_v1);
    poles.SetValue(3, curve_bz0_v2);
    poles.SetValue(4, curve_bz0_v3);
    Handle(Geom_BezierCurve) curve_bz0 = new Geom_BezierCurve(poles);
    Handle(Geom_BSplineCurve) e1_geom = GeomConvert::CurveToBSplineCurve(curve_bz0);

    BRepBuilderAPI_MakeEdge e0 = BRepBuilderAPI_MakeEdge(e1_geom);

    //////////////////////////////////////////////////////////////////////////

    gp_Pnt2d v0_2d(0, 0);
    float angle = 84.0*M_PI / 180.0;
    float dy = 4.21;
    float dx = dy * tan(angle);
    gp_Pnt2d v1_2d(dx, dy);

    gp_Pln plane_1(gp_Ax3(gp_Pnt(0, 0, 5), gp_Dir(1, 0, 0), gp_Dir(0, 1, 0)));
    Geom_Plane plane_geom1(plane_1);

    gp_Pnt cut_f_v1, cut_f_v2;
    plane_geom1.D0(v0_2d.X(), v0_2d.Y(), cut_f_v1);
    plane_geom1.D0(v1_2d.X(), v1_2d.Y(), cut_f_v2);

    TopoDS_Edge e = BRepBuilderAPI_MakeEdge(cut_f_v1, cut_f_v2);
    TopoDS_Face f1 = TopoDS::Face(BRepPrimAPI_MakePrism(e, gp_Vec(JiZhunXian1::v0.X() - 5, 0, 0)));

    /////////////////////////////////////////////////////////////////////////

    gp_Pln plane_2(gp_Ax3(curve_bz0_v3, gp_Dir(1, 0, 0), gp_Dir(0, 1, 0)));
    Geom_Plane plane_geom2(plane_2);

    float curve_bz2_dx_2d = 8.89;
    float curve_bz2_dy_2d = 10.65;
    gp_Pnt2d curve_bz2_v0_2d(0, 0);
    gp_Pnt2d curve_bz2_v3_2d(-curve_bz2_dx_2d, curve_bz2_dy_2d);
    gp_Pnt2d curve_bz2_v1_2d(curve_bz2_v0_2d.X(), curve_bz2_v3_2d.Y() / 2.0);

    gp_Vec2d v2d(0, -1);
    v2d.Rotate(60 * M_PI / 180);
    float len = curve_bz2_dx_2d / sin(60 * M_PI / 180);
    v2d.Multiply(len / 2);
    gp_Pnt2d curve_bz2_v2_2d(v2d.X() - curve_bz2_dx_2d, v2d.Y() + curve_bz2_dy_2d);

    gp_Pnt curve_bz2_v0, curve_bz2_v1, curve_bz2_v2, curve_bz2_v3;
    plane_geom2.D0(curve_bz2_v0_2d.X(), curve_bz2_v0_2d.Y(), curve_bz2_v0);
    plane_geom2.D0(curve_bz2_v1_2d.X(), curve_bz2_v1_2d.Y(), curve_bz2_v1);
    plane_geom2.D0(curve_bz2_v2_2d.X(), curve_bz2_v2_2d.Y(), curve_bz2_v2);
    plane_geom2.D0(curve_bz2_v3_2d.X(), curve_bz2_v3_2d.Y(), curve_bz2_v3);

    TopoDS_Edge e3;
    Handle(Geom_BSplineCurve) e3_geom;
    {
        TColgp_Array1OfPnt poles(1, 4);
        poles.SetValue(1, curve_bz2_v0);
        poles.SetValue(2, curve_bz2_v1);
        poles.SetValue(3, curve_bz2_v2);
        poles.SetValue(4, curve_bz2_v3);
        Handle(Geom_BezierCurve) curve_bz0 = new Geom_BezierCurve(poles);
        e3_geom = GeomConvert::CurveToBSplineCurve(curve_bz0);

        e3 = BRepBuilderAPI_MakeEdge(e3_geom);
    }

    /////////////////////////////////////////////////////////////////////////////////////////
    gp_Pln plane_3(gp_Ax3(curve_bz0_v0, gp_Dir(0, -1, 0), gp_Dir(1, 0, 0)));
    Geom_Plane plane_geom3(plane_3);

    float curve_bz3_dx_2d = 1.5;
    float curve_bz3_dy_2d = 6.0;
    gp_Pnt2d curve_bz3_v0_2d(0, 0);
    gp_Pnt2d curve_bz3_v3_2d(curve_bz3_dx_2d, curve_bz3_dy_2d);
    gp_Pnt2d curve_bz3_v1_2d(0, curve_bz3_dy_2d / 3);

    float curve_bz3_angle1 = 70.0 * M_PI / 180.0;
    float dx1 = curve_bz3_dx_2d * 2.0 / 5.0;
    float dy1 = dx1 * tan(curve_bz3_angle1);
    gp_Pnt2d curve_bz3_v2_2d(curve_bz3_v3_2d.X() - dx1, curve_bz3_v3_2d.Y() - dy1);

    gp_Pnt curve_bz3_v0, curve_bz3_v1, curve_bz3_v2, curve_bz3_v3;
    plane_geom3.D0(curve_bz3_v0_2d.X(), curve_bz3_v0_2d.Y(), curve_bz3_v0);
    plane_geom3.D0(curve_bz3_v1_2d.X(), curve_bz3_v1_2d.Y(), curve_bz3_v1);
    plane_geom3.D0(curve_bz3_v2_2d.X(), curve_bz3_v2_2d.Y(), curve_bz3_v2);
    plane_geom3.D0(curve_bz3_v3_2d.X(), curve_bz3_v3_2d.Y(), curve_bz3_v3);

    TopoDS_Edge e4;
    Handle(Geom_BSplineCurve) e4_geom;
    {
        TColgp_Array1OfPnt poles(1, 4);
        poles.SetValue(1, curve_bz3_v0);
        poles.SetValue(2, curve_bz3_v1);
        poles.SetValue(3, curve_bz3_v2);
        poles.SetValue(4, curve_bz3_v3);
        Handle(Geom_BezierCurve) curve_bz0 = new Geom_BezierCurve(poles);
        e4_geom = GeomConvert::CurveToBSplineCurve(curve_bz0);

        e4 = BRepBuilderAPI_MakeEdge(e4_geom);
    }

    // https://www.opencascade.com/content/how-can-i-get-intersection-point-two...
    gp_Pnt pnt6;
    {
        BRepExtrema_DistShapeShape disp(e3, f1);
        disp.Perform();
        float distence = disp.Value();
        if (distence <= Precision::Confusion())
        {
            pnt6 = disp.PointOnShape1(1);
            pnt6 = disp.PointOnShape2(1);
        }
    }

    gp_Pnt pnt7;
    {
        BRepExtrema_DistShapeShape disp(e4, f1);
        disp.Perform();
        float distence = disp.Value();
        if (distence <= Precision::Confusion())
        {
            pnt7 = disp.PointOnShape1(1);
            pnt7 = disp.PointOnShape2(1);
        }
    }

    ////////////////////////////////////////////////////////////////////////
    gp_Pnt curve1_bz_v0 = pnt7;
    gp_Pnt curve1_bz_v3 = pnt6;

    gp_Vec plane4_f_dir_y(cut_f_v1, cut_f_v2);
    gp_Vec plane4_f_dir_x(1, 0, 0);
    gp_Vec plane4_f_normal(plane4_f_dir_x.Crossed(plane4_f_dir_y));

    gp_Pln plane_4(gp_Ax3(cut_f_v1, plane4_f_normal, gp_Dir(1, 0, 0)));
    Handle(Geom_Plane) plane_geom4 = new Geom_Plane(plane_4);

    ShapeAnalysis_Surface sas(plane_geom4);
    gp_Pnt2d pnt6_uv = sas.ValueOfUV(pnt6, Precision::Confusion());
    gp_Pnt2d pnt7_uv = sas.ValueOfUV(pnt7, Precision::Confusion());

    gp_Pnt2d curve_bz1_v0_2d = pnt7_uv;
    gp_Pnt2d curve_bz1_v3_2d = pnt6_uv;
    ratio1 = 4.8 / 10.5;
    ratio2 = 6.1 / 6.7;
    gp_Pnt2d curve_bz1_v1_2d = gp_Pnt2d(curve_bz1_v0_2d.X(), curve_bz1_v3_2d.Y()*ratio1);
    gp_Pnt2d curve_bz1_v2_2d = gp_Pnt2d(curve_bz1_v0_2d.X()*ratio2, curve_bz1_v3_2d.Y());

    gp_Pnt curve_bz1_v0 = pnt7;
    gp_Pnt curve_bz1_v1 = plane_geom4->Value(curve_bz1_v1_2d.X(), curve_bz1_v1_2d.Y());
    gp_Pnt curve_bz1_v2 = plane_geom4->Value(curve_bz1_v2_2d.X(), curve_bz1_v2_2d.Y());;
    gp_Pnt curve_bz1_v3 = pnt6;

    TopoDS_Edge e2;
    Handle(Geom_BSplineCurve) e2_geom;
    {
        TColgp_Array1OfPnt poles(1, 4);
        poles.SetValue(1, curve_bz1_v0);
        poles.SetValue(2, curve_bz1_v1);
        poles.SetValue(3, curve_bz1_v2);
        poles.SetValue(4, curve_bz1_v3);
        Handle(Geom_BezierCurve) curve_bz0 = new Geom_BezierCurve(poles);
        e2_geom = GeomConvert::CurveToBSplineCurve(curve_bz0);

        e2 = BRepBuilderAPI_MakeEdge(e2_geom);
    }

    ///////////////////////////////////////////////////////////////////////////
    Standard_Real e3_geom_trim_u;
    GeomLib_Tool::Parameter(e3_geom, pnt6, Precision::Confusion(), e3_geom_trim_u);
    Handle(Geom_TrimmedCurve) e3_geom_trim = new Geom_TrimmedCurve(e3_geom, e3_geom->FirstParameter(), e3_geom_trim_u);
    Handle(Geom_BSplineCurve) e3_bsp_geom_trim = GeomConvert::CurveToBSplineCurve(e3_geom_trim);

    Standard_Real e4_geom_trim_u;
    GeomLib_Tool::Parameter(e4_geom, pnt7, Precision::Confusion(), e4_geom_trim_u);
    Handle(Geom_TrimmedCurve) e4_geom_trim = new Geom_TrimmedCurve(e4_geom, e4_geom->FirstParameter(), e4_geom_trim_u);
    Handle(Geom_BSplineCurve) e4_bsp_geom_trim = GeomConvert::CurveToBSplineCurve(e4_geom_trim);

    GeomFill_BSplineCurves fill;
    fill.Init(e1_geom, e3_bsp_geom_trim, e2_geom, e4_bsp_geom_trim, GeomFill_CoonsStyle);

    const Handle(Geom_BSplineSurface) surf = fill.Surface();

    TopoDS_Face f3 = BRepBuilderAPI_MakeFace(surf, Precision::Confusion());

    BRepOffset_MakeOffset myOffsetShape(f3, -offset_thick, 0.0001,
        BRepOffset_Skin,         //Mode              
        Standard_False,          //Intersection      
        Standard_False,          //SelfInter         
        GeomAbs_Intersection,      //Join              
        Standard_True,             //Thickening        
        Standard_False          //RemoveIntEdges
        );            //RemoveInvalidFaces

    TopoDS_Shape solid = myOffsetShape.Shape();

    std::vector<TopoDS_Edge> fillet2_edeges;
    {
        TopTools_IndexedDataMapOfShapeListOfShape M;
        TopExp::MapShapesAndAncestors(solid, TopAbs_EDGE, TopAbs_FACE, M);
        for (int i = 1; i < M.Extent(); i++)
        {
            TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
            fillet2_edeges.push_back(E);
        }
    }

    BRepFilletAPI_MakeFillet MF2(solid);
    MF2.Add(1.0, fillet2_edeges[2 - 1]);
    //MF2.Add(1.5, fillet2_edeges[1 - 1]);

    // final shape 
    TopoDS_Shape step2_solid_fillet2 = MF2.Shape();

    StlAPI_Writer myStlWriter;
    myStlWriter.Write(step2_solid_fillet2, "temp.stl");

Forum supervisor's picture

Dear Kate,

Please specify the values for variables "offset_thick" and "JiZhunXian1::v0.X()" used in that code.

Best Regards, FSR

Kate Ken's picture

Dear Admin,

My bad, i forgot this, 

double offset_thick = 3;

Best regards,

Forum supervisor's picture

Dear Kate,

We cannot reproduce the problem on OCCT 7.1.0 (tried on VS 2010 64-bit).

Two remarks:

  • In order to export to STL, the shape must be first tessellated (otherwise exported file is empty). We used BRepMesh_IncrementalMesh with default options.
  • The generated shape looks differently from the one shown in the first post -- see image below.

Best Regards, FSR

Kate Ken's picture

Dear admin:

yesThank you very much, now i know the fact, smileyif i wan't beautifull mesh, i can use BRepMesh_IncrementalMesh to achive the goal. 

thanks again for you patient and your support!

Best Regards.