DiscussionsIssue archiveModeling Data and Algorithms

Archived discussion

Why BOPAlgo_Builder can not work

Modeling Data and AlgorithmsMon, 07/08/2024 - 06:188 replies

Browse this forum
QuestionAuthor

I use BOPAlgo_Builder to cut one TopoDS_Face by another TopoDS_Face.
You will see that in picture1.png
I use intersectedFaces[5_0_0].brep cut inputFacePieces[5_0_0].brep
The version of occ is 7.6
Nothing changed
I want to know what is wrong with that result
So I wanna debug OCC sources in Visual Studio in windows to see data changing in runtime of BOPAlgo_Builder
But I do not know how to do that,I know how to build OCC sources,I also know how to install occ products.
My question is how to see the data of runtime in BOPAlgo_Builder when breakpointing it.
Why nothing changed?

Discussion

8 archived replies

Posts are displayed in their archived order.

01Commenter-1

Hello, you would like to debug OCCT project itself from DRAW?

For debugging DRAW you need to specify build type to Debug or ReleaseWitgDebInfo. And start with debugging DRAWEXE, or attach to process.

In case of you want to debug your own application, you need to install occt with previous types (debug/relwithdebinfo).

After installing you need to connect installed CMake project. Need to link debug lins with your debug configuration. One of the available samples for CMake:

https://github.com/dpasukhi/DE_Wrapper-Sample

https://github.com/dpasukhi/DE_Wrapper-Sample/blob/main/src/CoreDE/CMake...

Best regards, Commenter-1.

02Author

Thank you I have done this myself already.
My question now is changed to why BOPAlgo_Builder can not work.

03Commenter-1

For helping you, we need to have DRAW script to reproduce or the c++ code sample. The reason mainly for that type of issue is tolerance, try to increase tolerance for your operation.

Additionally, it will be better, if you will check on the latest version (it can be a old bug).

Best regards, Commenter-1.

04Author

Tools::readShapeFromBRep is a custom function I wrote,for reading TopoDS_Shape from file.
You can read file in your way

05Author

SPDLOG_DEBUG is a third library for printing log,you can std::cout instead.

06Author
const TopoDS_Face one = TopoDS::Face(Tools::readShapeFromBRep("D:/share/intersectedFaces[5_0_0].brep"));
const TopoDS_Face two = TopoDS::Face(Tools::readShapeFromBRep("D:/share/inputFacePieces[5_0_0].brep"));
SPDLOG_DEBUG("one tolerance is {} , two tolerance is {}", BRep_Tool::Tolerance(one), BRep_Tool::Tolerance(two));
for (TopExp_Explorer ex(one, TopAbs_EDGE); ex.More(); ex.Next())
{
    SPDLOG_DEBUG("edge tolerance is {}", BRep_Tool::Tolerance(TopoDS::Edge(ex.Current())));
}
for (TopExp_Explorer ex(two, TopAbs_EDGE); ex.More(); ex.Next())
{
    SPDLOG_DEBUG("edge tolerance is {}", BRep_Tool::Tolerance(TopoDS::Edge(ex.Current())));
}
for (TopExp_Explorer ex(one, TopAbs_VERTEX); ex.More(); ex.Next())
{
    SPDLOG_DEBUG("vertex tolerance is {}", BRep_Tool::Tolerance(TopoDS::Vertex(ex.Current())));
}
for (TopExp_Explorer ex(two, TopAbs_VERTEX); ex.More(); ex.Next())
{
    SPDLOG_DEBUG("vertex tolerance is {}", BRep_Tool::Tolerance(TopoDS::Vertex(ex.Current())));
}
BOPAlgo_Builder fuseBuilder;
Standard_Real localTolerance = 1e-4;
fuseBuilder.SetNonDestructive(Standard_True);
fuseBuilder.SetFuzzyValue(localTolerance);
fuseBuilder.SetParallelMode(Standard_True);
BRepBuilderAPI_Copy inputFaceCopyTool;
inputFaceCopyTool.Perform(one, Standard_True, Standard_True);
const TopoDS_Face copiedToolFace = TopoDS::Face(inputFaceCopyTool.Shape());
fuseBuilder.AddArgument(copiedToolFace);
inputFaceCopyTool.Perform(two, Standard_True, Standard_True);
const TopoDS_Face copiedInputFace = TopoDS::Face(inputFaceCopyTool.Shape());
fuseBuilder.AddArgument(copiedInputFace);
fuseBuilder.Perform();
if (fuseBuilder.HasErrors() || fuseBuilder.HasWarnings())
{
    std::stringstream warningStream;
    fuseBuilder.DumpWarnings(warningStream);
    std::stringstream errorStream;
    fuseBuilder.DumpErrors(errorStream);
    SPDLOG_DEBUG("警告是 {} 错误是 {}", warningStream.str(), errorStream.str());
}
std::vector<TopoDS_Face> cuttedFaces;
TopoDS_ListOfShape cutShapeList = fuseBuilder.Modified(copiedInputFace);
SPDLOG_DEBUG("面片碎片的个数是 {}", cutShapeList.Extent());
size_t index = 0;
for (TopoDS_ListIteratorOfListOfShape iterator(cutShapeList);iterator.More();iterator.Next())
{
    Tools::writeShapeToBRep(iterator.Value(), "C:/Users/27343/Downloads/extendOneFirst" + std::to_string(index++) + ".brep");
}

Here is the code above

07Commenter-2

Anytime you get unexpected or no results from an algorithm, you should verify your input shapes. You can do that with BRepCheck_Analyzer. When you do that with 'inputFacePieces[5_0_0]' you will see a bunch of errors. Once those are fixed the boolean operation will probably work ... at least it did for me.

08Author

I got it done in your way
And fix the invalid TopoDS_Face using ShapeFix_Face
Thank you very much