Boolean operations and transformations in TopoDS_Shape

Open CASCADE 5.2 public

I'm operating on FACES of TopoDS_Shape objects (I need only triangulation data from Mesh()).

Is there any way to get correct vertices position in 3D space AFTER boolean operation (f.e. Fuse) IF shapes has transformations inside (shape.Move(transformation))??

The problem is: the shape's faces that are f.e. fusing together are moved to new position (position after Move()); the rest of shape's faces are in their "local"/original/start/creation position, as if they don't Move into new postition... The object (f.e. Box) is DISJUNCTIVED into two fragments, faces that fusing with another object and faces that are not fusing at all.

What to do to know which faces need to be moved manually?? Or is there any API that moves it for me?? How about the visualization engine (I'm not using it, I need only triangulation)?

John Brown's picture

OK, now I got it.
boolean operations does not update locations of not-fusing faces.
BRepTool::Triangulation() does not update location of faces.

Solution is to manually Transform() vertices by location from Face:
TopLoc_Location L;
Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L);
//...
const gp_Trsf & trsf = L.Transformation();
//... nodes from face
gp_Pnt v1 = nodes(node1);
v1.Transform( trsf );

:-P

Jianming Zhang's picture

Hello,

I have a similar task as you, in which I need to mesh a general surface in its parametric space. Do you know the data structure in OCC to represent a trimmed furface (after boolean operation a surface is trimmed or maybe have holes in it) or in which file I can find the data structure?

Thanks in advance!
Jianming

John Brown's picture

For my Shape I'm iterating over faces, getting Traingulation data (nodes and triangles) and read 3D (vertex) position from them:
for ( TopExp_Explorer ex( gd.Get(), 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=nTriangles; i >= 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 :)
}
}

John Brown's picture

As you I'm using only triangulation data, the surface data is helpful when I'm computing normals in each vertex.
I can't understand exeactly what are you trying to do... Do you need surface as Surface-type, or are you talking about meshed-surface?
Generally Shape is divided into faces, faces are meshed. After boolean operation some face may be deleted, created, modified.

Jianming Zhang's picture

Thank you for your quick repley.
I am trying mesh a surface in its parametric space, but not necessarily using triangulation. My meshing method is relatively simpler, for example, just using retangular patches to cover the parametric domain of the surface. However, when the suface is trimmed, some of the patches may intersect with the trimming curves. My question is how to get the trimming curves. Using the UVBound method we can only obtain the ranges of the parameters U and V.