View Issue Details

IDProjectCategoryView StatusLast Update
0030417CommunityOCCT:Modeling Algorithmspublic2019-02-06 10:26
Reporterabezotosniy Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionno change required 
Platform64 bitOSWindows 
Product Version7.3.0 
Summary0030417: BRepAlgoAPI_Cut produces incorrect result.
DescriptionIf faced with the problem when BRepAlgoAPI_Cut produces incorrect result.
Please see example.
Steps To Reproduce1. Download cut_args.brep and put it into ${opencascade-7.3.0}\data\occ

2. Replace corresponding method in ${opencascade-7.3.0}\samples\mfc\standard\02_Modeling\src\ModelingDoc.cpp

void CModelingDoc::OnCut()
{
    AIS_ListOfInteractive aList;
    myAISContext->DisplayedObjects(aList);
    AIS_ListIteratorOfListOfInteractive aListIterator;
    for(aListIterator.Initialize(aList); aListIterator.More(); aListIterator.Next())
    {
        myAISContext->Remove(aListIterator.Value(), Standard_False);
    }

    // Read arguments
    TopoDS_Shape compound;
    {
        std::filebuf aFileBuf;
        std::istream aStream(&aFileBuf);

        CString tool_file;
        tool_file.GetEnvironmentVariable(L"CSF_OCCTDataPath");
        tool_file += "\\occ\\cut_args.brep";

        if(!aFileBuf.open(tool_file, ios::in))
        {
            AfxMessageBox(L"File not found");
            return;
        }

        BRep_Builder aBuilder;
        BRepTools::Read(compound, aStream, aBuilder);
    }

    std::vector<TopoDS_Shape> args;
    for(TopoDS_Iterator exp(compound); exp.More(); exp.Next())
    {
        args.push_back(exp.Value());
    }

    if(args.size() < 2)
    {
        AfxMessageBox(L"Invalid number of arguments");
        return;
    }

    // Prepare Argument
    TopoDS_Shape cut_arg = args[0];
    Handle(AIS_Shape) ais_cut_arg = new AIS_Shape(cut_arg);
    myAISContext->SetDisplayMode(ais_cut_arg, 1, Standard_False);
    myAISContext->SetColor(ais_cut_arg, Quantity_NOC_GREEN, Standard_False);
    myAISContext->SetMaterial(ais_cut_arg, Graphic3d_NOM_PLASTIC, Standard_False);
    myAISContext->Display(ais_cut_arg, Standard_False);
    const Handle(AIS_InteractiveObject)& io_cut_arg = ais_cut_arg;
    myAISContext->SetSelected(io_cut_arg, Standard_False);
    Fit();
    Sleep(1000);

    // Prepare Tool
    TopoDS_Shape cut_tool = args[1];
    // With the same cylinder, but with a different radius, it works correctly
    // TopoDS_Shape cut_tool = args[2];
    Handle(AIS_Shape)ais_cut_tool = new AIS_Shape(cut_tool);
    myAISContext->SetDisplayMode(ais_cut_tool, 1, Standard_False);
    myAISContext->SetColor(ais_cut_tool, Quantity_NOC_YELLOW, Standard_False);
    myAISContext->SetMaterial(ais_cut_tool, Graphic3d_NOM_PLASTIC, Standard_False);
    myAISContext->Display(ais_cut_tool, Standard_False);
    const Handle(AIS_InteractiveObject)& io_cut_tool = ais_cut_tool;
    myAISContext->SetSelected(io_cut_tool, Standard_False);
    Fit();
    Sleep(1000);

    // Perform Cut
    TopoDS_Shape cut_shape = BRepAlgoAPI_Cut(cut_arg, cut_tool);

    myAISContext->Erase(io_cut_tool, Standard_False);
    myAISContext->Erase(io_cut_arg, Standard_False);

    Handle(AIS_Shape) ais_cut = new AIS_Shape(cut_shape);
    myAISContext->SetDisplayMode(ais_cut, 1, Standard_False);
    myAISContext->SetColor(ais_cut, Quantity_NOC_RED, Standard_False);
    myAISContext->SetMaterial(ais_cut, Graphic3d_NOM_PLASTIC, Standard_False);
    myAISContext->Display(ais_cut, Standard_False);
    const Handle(AIS_InteractiveObject)& io_cut = ais_cut;
    myAISContext->SetSelected(io_cut, Standard_False);
    Fit();
}

3. Run method.
TagsNo tags attached.
Test case number

Attached Files

  • cut_args.brep (83,748 bytes)
  • result.jpg (23,486 bytes)

Activities

abezotosniy

2018-12-17 21:28

reporter  

cut_args.brep (83,748 bytes)

msv

2018-12-18 09:39

developer   ~0081543

The argument of the boolean operation is invalid. The face is defined out of bounds of the surface. The brep checker reports such error:
Draw[61]> checkshape a_1
On Shape faulty_1 :
BRepCheck_InvalidRange
On Shape faulty_2 :
BRepCheck_InvalidRange
On Shape faulty_3 :
BRepCheck_InvalidRange
On Shape faulty_4 :
BRepCheck_InvalidRange

Faulty shapes in variables faulty_1 to faulty_4


A part of section line between arguments goes out of the surface of the first argument, but inside the bounds of the face. This inconsistency leads to incorrect result.

The draw script to show the inconsistency:
explode a_1 f
mksurface su a_1_1
xbounds a_1_1

-75.1543
76.694
-75.9401
70.5117

dump su

 UKnots :
   1 : -53.4616506165414 4
   2 : 55.001369407119 4

 VKnots :
   1 : -54.2474993354269 4
   2 : 48.8191095354809 4

msv

2018-12-18 09:51

developer  

result.jpg (23,486 bytes)

abezotosniy

2019-01-25 18:23

reporter   ~0081886

Got it.
Thank you!

msv

2019-01-25 18:33

developer   ~0081887

Dear bugmaster, please close this bug. No changes are required.

Issue History

Date Modified Username Field Change
2018-12-17 21:28 abezotosniy New Issue
2018-12-17 21:28 abezotosniy Assigned To => msv
2018-12-17 21:28 abezotosniy File Added: cut_args.brep
2018-12-18 09:39 msv Note Added: 0081543
2018-12-18 09:40 msv Assigned To msv => abezotosniy
2018-12-18 09:40 msv Status new => feedback
2018-12-18 09:51 msv File Added: result.jpg
2019-01-25 18:23 abezotosniy Note Added: 0081886
2019-01-25 18:33 msv Note Added: 0081887
2019-01-25 18:33 msv Assigned To abezotosniy => bugmaster
2019-01-25 18:33 msv Resolution open => no change required
2019-02-06 10:26 bugmaster Status feedback => closed