View Issue Details

IDProjectCategoryView StatusLast Update
0033697CommunityOCCT:Modeling Algorithmspublic2024-04-30 09:40
Reportersheblykin Assigned Tooan  
PrioritynormalSeveritymajor 
Status newResolutionopen 
PlatformWindowsOSVC++ 2019 
Product Version7.8.0 
Summary0033697: Modeling Algorithms - Base Torus Surfaces are not trimmed by wires
DescriptionI have written a plugin for autocad in c# that does geometry export via iges through opencascad wrapper.
In library version 7.4.0 Torus Surface are created without errors, starting from version 7.5.0 Torus Surface
are no longer cut by Wires. No such error was encountered with other surfaces.
Below is the code that builds the surface using data from autocad Brep view.
Steps To Reproducecall AddTorusSurface in 7.4.0 version and in 7.5.0 or higher and compare result
Please see result in the attached files
Standard_Boolean AddTorusSurface(gp_Pnt^ sp, gp_Vec^ normal, double MajorRadius, double MinorRadius)
{
    ::gp_Dir dir(*(normal->ObjRef()));
    ::gp_Ax3 ax3(*(sp->ObjRef()), dir);
    //::gp_Torus torus(ax3, MajorRadius, MinorRadius);
    Handle(Geom_ToroidalSurface) torus = new Geom_ToroidalSurface(ax3, MajorRadius, MinorRadius);
    return m_Impl->AddShape(MakeFace(torus));
}

Handle(TopTools_HSequenceOfShape) ConnectEdgesToWires(bool isVoid)
{
    double tolerance = 0.001;
    bool shared = false;
    Handle(TopTools_HSequenceOfShape) Wires = new TopTools_HSequenceOfShape();
    Handle(TopTools_HSequenceOfShape) Edges = new TopTools_HSequenceOfShape();
    if (isVoid)
    {
        for (::TopoDS_Edge edge : *listOfVoidEdge)
        {
            Edges->Append(edge);
        }
        listOfVoidEdge->Clear();
        ShapeAnalysis_FreeBounds::ConnectEdgesToWires(Edges, tolerance, shared, Wires);
    }
    else
    {
        for (::TopoDS_Edge edge : *listOfEdge)
        {
            Edges->Append(edge);
        }
        listOfEdge->Clear();
        ShapeAnalysis_FreeBounds::ConnectEdgesToWires(Edges, tolerance, shared, Wires);
    }
    return Wires;
}

::TopoDS_Face ShapeFixFace(BRepBuilderAPI_MakeFace face)
{
    ShapeFix_Face aFaceFixer;
    aFaceFixer.FixWireMode() = 1;
    aFaceFixer.FixOrientationMode() = 1;
    aFaceFixer.FixSplitFaceMode() = 1;
    Handle(ShapeFix_Wire) aWireFixer = aFaceFixer.FixWireTool();
    aWireFixer->FixConnectedMode() = 1;
    aWireFixer->ClosedWireMode() = Standard_True;
    Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape();
    aFaceFixer.SetContext(aContext);
    aFaceFixer.Init(face);
    aFaceFixer.Perform();
    return TopoDS::Face(aFaceFixer.Result());
}

::TopoDS_Shape MakeFace(const Handle(Geom_Surface) S)
{
    Handle(TopTools_HSequenceOfShape) Wires = ConnectEdgesToWires(false);
    BRepBuilderAPI_MakeFace region;
    if (Wires->Length() > 0)
    {
        BRepBuilderAPI_MakeFace F = BRepBuilderAPI_MakeFace(S, TopoDS::Wire(Wires->Value(1)));
        if (Wires->Length() > 1)
        {
            region = BRepBuilderAPI_MakeFace(F.Face(), TopoDS::Wire(Wires->Value(Wires->Length())));
        }
        else
        {
            region = F;
        }
    }
    else
    {
        region.Init(S, true, 1e-5);
    }
    Handle(TopTools_HSequenceOfShape) WiresVoid = ConnectEdgesToWires(true);
    for (int i = 1; i <= WiresVoid->Length(); i++)
    {
        region.Add(TopoDS::Wire(WiresVoid->Value(i)));
    }

    ::TopoDS_Shape shape = ShapeFixFace(region);
    GProp_GProps prop;
    BRepGProp::SurfaceProperties(shape, prop);
    if (prop.Mass() < 0)
    {
        BRepBuilderAPI_MakeFace R;
        BRepBuilderAPI_MakeFace F(S, TopoDS::Wire(Wires->Value(1)));
        if (Wires->Length() > 1)
        {
            R = BRepBuilderAPI_MakeFace(ShapeFixFace(BRepBuilderAPI_MakeFace(F.Face(), TopoDS::Wire(Wires->Value(Wires->Length())))));
        }
        else
        {
            R = BRepBuilderAPI_MakeFace(ShapeFixFace(F));
        }
        for (int i = 1; i <= WiresVoid->Length(); i++)
        {
            R.Add(TopoDS::Wire(WiresVoid->Value(i)));
        }
        if (WiresVoid->Length() > 0)
        {
            shape = ShapeFixFace(R);
        }
    }
    WiresVoid->Clear();
    Wires->Clear();
    return shape;
}
TagsNo tags attached.
Test case number

Attached Files

  • good.png (68,670 bytes)
  • error.png (85,937 bytes)
  • error.iges (74,277 bytes)
  • good.iges (65,928 bytes)

Activities

sheblykin

2024-04-27 12:27

reporter  

good.png (68,670 bytes)
error.png (85,937 bytes)
error.iges (74,277 bytes)
good.iges (65,928 bytes)

sheblykin

2024-04-27 14:55

reporter   ~0115768

We checked the issue in 7.5.0, 7.6.0, 7.7.0, 7.8.0 (current latest vesion) and the issue was reproduced on all of them. (It works fine in 7.4.0)
Looks like something was changed globaly for torus in 7.5.0 version as we can see in the source code and after that it was broken.

sheblykin

2024-04-30 09:40

reporter   ~0115770

I checked again in 7.5.0 and 7.6.0 the test case works fine, but in 7.7.0 and 7.8.2 it does not work

Issue History

Date Modified Username Field Change
2024-04-27 12:27 sheblykin New Issue
2024-04-27 12:27 sheblykin Assigned To => oan
2024-04-27 12:27 sheblykin File Added: good.png
2024-04-27 12:27 sheblykin File Added: error.png
2024-04-27 12:27 sheblykin File Added: error.iges
2024-04-27 12:27 sheblykin File Added: good.iges
2024-04-27 14:02 dpasukhi Summary Base Torus Surfaces are not trimmed by wires => Modeling Algorithms - Base Torus Surfaces are not trimmed by wires
2024-04-27 14:02 dpasukhi Steps to Reproduce Updated
2024-04-27 14:02 dpasukhi Additional Information Updated
2024-04-27 14:55 sheblykin Note Added: 0115768
2024-04-30 09:40 sheblykin Note Added: 0115770