Okay, I managed to get past this with the following code:
TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,40,40);
TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100,20,20),80);
TopoDS_Shape ShapeCut;
BRepAlgoAPI_Cut aCutOperation(theBox, theSphere);
if (aCutOperation.IsDone()) { // triangulate}
Now I have trouble triangulating.
The code I am using is as follows (which I got from the forum):
ShapeCut = aCutOperation.Shape();
for ( TopExp_Explorer ex( ShapeCut, TopAbs_FACE ) ; ex.More(); ex.Next() )
{
TopoDS_Face F = TopoDS::Face(ex.Current());
// Get triangulation
TopLoc_Location L;
Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L);
const Poly_Array1OfTriangle & triangles = facing->Triangles();
const TColgp_Array1OfPnt & nodes = facing->Nodes();
for ( int i=triangles.Upper(); i >= triangles.Lower()+1; --i ) // (indeksy 1...N)
{
Poly_Triangle triangle = triangles(i);
Standard_Integer node1,node2,node3;
triangle.Get(node1, node2, node3);
gp_Pnt v1 = nodes(node1);
gp_Pnt v2 = nodes(node2);
gp_Pnt v3 = nodes(node3);
// now we need to transform vertices
// don't forget about face orientation :)
}
I am using my own renderer, so am not using any of open cascade's display functionality. Should I be using another function as well? I read somewhere that I might be able to use BRepMesh::IncrementalMesh, but am not sure how to use it in this setup.