Splitting shape

Hi,
i have a TopoDS_Shape (composed only by faces) and i need to split it using a polyline (open or closed).

I would like to know which is the better (faster and precise) way to do this kind of operation.

I have tried several approach using the Split feat but it doesn't work very well (in a lot of cases it doesn't split the shape).

Should i work face by face?

devil20's picture

Hi

I am also intersted in Shape Spilting . Please let me know if you find any solution around that.

PG's picture

U need to look into the
Samples->MFC->TopologicalLocalOperations

I am not sure this is what u mean by splitting a shape (see the code below)
===================================================================
TopoDS_Shape S = BRepPrimAPI_MakeBox(gp_Pnt(-100,-60,-80),150,200,170);

BRepBuilderAPI_Section asect(S, gp_Pln(1,2,1,-15),Standard_False);
asect.ComputePCurveOn1(Standard_True);
asect.Approximation(Standard_True);
asect.Build();
TopoDS_Shape R = asect.Shape();

BRepFeat_SplitShape asplit(S);

for (TopExp_Explorer Ex(R,TopAbs_EDGE); Ex.More(); Ex.Next()) {
TopoDS_Shape anEdge = Ex.Current();
TopoDS_Shape aFace;
if (asect.HasAncestorFaceOn1(anEdge,aFace)) {
TopoDS_Face F = TopoDS::Face(aFace);
TopoDS_Edge E = TopoDS::Edge(anEdge);
asplit.Add(E,F);
}
}

asplit.Build();

TopoDS_Shape Result = asplit.Shape();

=============================================

Sharjith Naramparambath's picture

Please download the additional samples from the site. It has an example of shape splitting. The example is SplitShape.exe

You ca download it from http://files.opencascade.com/OCC_6.2_release/allsamples.zip

Regards
N. Sharjith

Davide Canalia's picture

Thank you very much!

devil20's picture

Hi

But in the allsamples.zip doesnot have any source codes. Where can i get source codes ?

Davide Canalia's picture

I have seen the sample.
I have tried it and with some of my shapes it doesn't work.
It give me a "crash" during aSplitter.build().

The shape i want to split is build of only one face with 2 holes.
So the section i get is not a single wire but 3 non connected edges.
(i have skipped the wire creation in the sample code due to this situation).

The section is computed, i can see the 3 edges. When i try to split i get the crash.

What can i check to solve this problem?
i have tried to heal the shape, the edges, the faces i add to the splitter...

Davide Canalia's picture

I have performed more test.
Here is "scene":
1) one wire ( 1 linear edge) W
2) a prism P built from W
3) a shape S built by 1 face F with 2 holes

If i split in a part of S where i don't intersect the holes all it's ok. If not i get a crash during the build method of the splitter.

To avoid the crash i have to project W on the surface of F. So it works (pW = projected wire).

But (...) projecting I have a worst performance, and in some case (very vertical faces) i get a crash during build cause pW is open and do not intersect the outer bound of F....