Cutting Shape Results

Hi there,

At the moment I have a a TopoDS_Shape which I want to cut using a plane.
At first I create a TopoDS_Shape for the cutting plane as well. Next I get the Intersection between the plane and the object using

TopoDS_Shape Intersection = BRepAlgo_Section(object, plane);

Then I calculate the actual cut using

BRepAlgoAPI_Cut aCut(objectShape, cutPlane1);
TopoDS_Shape aResult1 = aCut.Shape();

But the resulting cut object happens to 'open' where I cut them, therefore I use the Intersection I calculated to close it again and sew them together using

BRepBuilderAPI_Sewing sew;
sew.Add(aResult1);
sew.Add(Intersection);
sew.Perform();

This works perfectly but I was wondering if there was a way to cut the object with the plane without having to 'close' the cut object afterwards.

Another problem that I'm wondering about is:
What if the cutting plane doesn't create only one new shape but 2 or more (I'll try to show what I mean)

Let this be the object I want to cut:

| |
| |
| |
|_______|

if I want to cut it right there with this plane

| |
| |
------------ | |
|_______|

the upper part results in 2 new objects which are not connected, but the cutting operation only returns 1 TopoDS_Shape.
Would the cutting actually work and is there a way find out how many individual objects there are in the cut object and to separate them into individual TopoDS_Shapes ?

I hope this made some sense, since English is not my native language.
I would be very happy if someone could help me with one of my questions. If not, I still want to thank you for reading it.

manika's picture

sorry for double posting

manika's picture

this was supposed to look like this
|.......|
|.......|
------------ <-- plane
|.......|
|_______|

the result should be two separate
|......|
|......|

Bearloga's picture

The Section operation returns a compound of edges, and it does not contain any object that can be candidate for covering the opening. Therefore I wonder if after sewing you obtain a closed object.
The Cut operation returns open object because your shapes are not solids. First, your shape should be solid. Second, make half-space solid from your plane (BRepPrimAPI_MakeHalfSpace).

manika's picture

that's right, the Intersection consists only of edges, I use and an TopExp_Explorer to go through all the edges and add them to a wire using BRepBuilderAPI_MakeWire and then create a face of the wire using BRepBuilderAPI_MakeFace. The resulting Face is used to cover the opening.
I will definitely try it with solids. The name already suggests that it should work. Thank you so far.

Hesham Nasif's picture

Dear Mr. Bearloga
Would you please explain about a creation of half space and how can we choose the ref point. Please give an example
Thanks