MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0030417Community[OCCT] OCCT:Modeling Algorithmspublic2018-12-17 21:282019-01-09 20:27
Reporterabezotosniy 
Assigned Toabezotosniy 
PrioritynormalSeverityminor 
StatusfeedbackResolutionopen 
Platform64 bitOSWindowsOS VersionVC++ 2017
Product Version[OCCT] 7.3.0 
Target VersionFixed in Version 
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? file icon cut_args.brep (83,748 bytes) 2018-12-17 21:28
jpg file icon result.jpg (23,486 bytes) 2018-12-18 09:51

- Relationships

-  Notes
(0081543)
msv (developer)
2018-12-18 09:39

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

- 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


Copyright © 2000 - 2019 MantisBT Team
Powered by Mantis Bugtracker