Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forum
Open Source community
Training and e-learning
A la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
News
Home / Developer Corner / Forum / creating solids for boolean operations

Forum

creating solids for boolean operations
Vivek Verma2004/03/25 22: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<4; ++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);
CTavernier2004/03/26 10: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
Björn Hagemeier2004/10/20 10: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
 
 
Latest news
  • FAQ section updated
  • OPEN CASCADE Uses Intel ® Parallel Studio XE to Introduce Parallelism into SALOME SMESH Module
  • Open CASCADE Technology 6.5.2 is available for download!

  • © OPEN CASCADE 2000 - 2012  |  Search  |  Contacts   |  Site map