Fri, 03/26/2004 - 00:00
I have a closed triangulated surface that I would like to combine with other solids using boolean operations but the program crashes during the boolean operation. Could someone please tell me what I am doing wrong? I suspect that I am not creating the solid object correctly from my triangulated surface but I don't know if there is a better way to create a solid from a set of triangles.
I would greatly appreciate any help.
thanks,
-vivek
The following illustrates what I am doing:
  // create a tetrahedron from points
  //
  // vertices->edges->wires->faces->shell
  gp_Pnt v1(1, 0, 0);
  gp_Pnt v2(0, 1, 0);
  gp_Pnt v3(0, 0, 1);
  gp_Pnt v4(0, 0, 0);
  // first create edges
  TopoDS_Edge e[6];
  e[0] = BRepBuilderAPI_MakeEdge(v1,v4);
  e[1] = BRepBuilderAPI_MakeEdge(v4,v2);
  e[2] = BRepBuilderAPI_MakeEdge(v4,v3);
  e[3] = BRepBuilderAPI_MakeEdge(v2,v1);
  e[4] = BRepBuilderAPI_MakeEdge(v3,v2);
  e[5] = BRepBuilderAPI_MakeEdge(v3,v1);
  // now create wires
  //
  TopoDS_Wire w[4];
  w[0] = BRepBuilderAPI_MakeWire(e[5], e[3], e[4]);
  w[1] = BRepBuilderAPI_MakeWire(e[1], e[3], e[0]);
  w[2] = BRepBuilderAPI_MakeWire(e[0], e[5], e[2]);
  w[3] = BRepBuilderAPI_MakeWire(e[2], e[4], e[1]);
  // use the above wires to create faces
  //
  TopoDS_Face f[4];
  f[0] = BRepBuilderAPI_MakeFace(w[0]);
  f[1] = BRepBuilderAPI_MakeFace(w[1]);
  f[2] = BRepBuilderAPI_MakeFace(w[2]);
  f[3] = BRepBuilderAPI_MakeFace(w[3]);
  // sew the faces together to create a shell
  //
  BRepOffsetAPI_Sewing Sew;
  for(int j=0; j
    Sew.Add(f[j]); 
  Sew.Perform();
  TopoDS_Shape shell= Sew.SewedShape();
  // create a solid box
  //
  gp_Pnt P(0,0,0);
  TopoDS_Shape theBox = BRepPrimAPI_MakeBox(0.5,0.5,0.5);
  // fuse the tetrahedron with the box
  // -- this is where the program crashes
  //
  TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox,shell);
        
Fri, 03/26/2004 - 12:50
Hi Vivek,
Replace the end of your code with:
-------------------------------------------------
Sew.Perform();
TopoDS_Shape shape = Sew.SewedShape();
TopoDS_Shell shell = TopoDS::Shell(shape);
// Create a SOLID tetrahedron
TopoDS_Solid solid = BRepBuilderAPI_MakeSolid(shell);
solid.Reverse();
// Create a solid box
TopoDS_Shape theBox = BRepPrimAPI_MakeBox(0.5,0.5,0.5);
// Fuse the SOLID tetrahedron with the box
TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox,solid);
-------------------------------------------------
It should work.
I also reverse the solid tetrahedron to have a good result.
Regards,
Christian
Wed, 10/20/2004 - 12:01
Hi Christian,
I know you've made your posting a long while ago. I'm having trouble using similar code. Actually I tried your suggestion, too. I have a rather large wireframe model of ~60000 triangles, but I can't get a valid sewed shape from the sewer (TypeMismatch). Do you know any solution? I also need to create a solid for boolean operations.
Regards,
Björn