converting the shape of the boolean operation result into solid crashed

Hi all,

I want to convert the shape of the boolean operation result into solid, but crashed. I confirmed the shape type is solid, really don't know what is the problem. Below is the code script. Could any one help me out? Thanks in advance~

  BRepAlgoAPI_Fuse fuser(outShape, midShape);  //outShape and midShape are solid
  fuser.SetRunParallel(1);
  fuser.SetUseOBB(1);
  fuser.Build();
  TopoDS_Solid solid = TopoDS::Solid(fuser.Shape());//crashed here, and i confirmed fuer.shape() is a solid
Eugeny's picture

Most likely the result is not a solid, but the compound containing solid. Use TopExp_Explorer or TopoDS_Iterator to get the solid out of the compound:

TopoDS::Solid(TopoDS_Iterator(fuser.Shape()).Value())
xing li's picture

Thanks for your reply! I tried use TopoDS_Iterator to go through the shape ,and it only contained one shape and turned out to be a solid. Below is the code snap:

  TopoDS_Shape outMidShape;
  if (fuser.IsDone()) {
    outMidShape = fuser.Shape();

 
    for (TopoDS_Iterator iter(outMidShape); iter.More(); iter.Next()) {
      TopoDS_Shape s = iter.Value();
      qDebug() << "s: " << s.ShapeType();
    }
  }

the debug result is s: 2

xing li's picture

Thanks for your reply! I tried use TopoDS_Iterator to go through the shape ,and it only contained one shape and turned out to be a solid. Below is the code snap:

  TopoDS_Shape outMidShape;
  if (fuser.IsDone()) {
    outMidShape = fuser.Shape();

 
    for (TopoDS_Iterator iter(outMidShape); iter.More(); iter.Next()) {
      TopoDS_Shape s = iter.Value();
      qDebug() << "s: " << s.ShapeType();
    }
  }

the debug result is s: 2

Eugeny's picture

That's correct. Compound containing only one solid. My proposal should work. TopoDS_Iterator iterates over one-level deep sub-shapes of the shape. For solids it will be shells, for shells - faces, etc.

xing li's picture

You are right! Thank you very much~