Incorrect face deletion on shape-plane cutting

Hi,
we are currently trying to implement a cutting algorithm for our already discretised geometry. In this example, the geometry is a cigar-shaped solid made out of circumferential faces as shown in the first image. The second image shows the cutting plane as well which is scaled during the algorithm to overspread the full geometry. However, after the cut is done, the face the plane "enters" the geometry is missing completly afterwards. This does only happen on some occasions and I can't really figure out why.

http://imageshack.us/photo/my-images/836/cuttingfail0.png/
http://imageshack.us/photo/my-images/37/cuttingfail1.png/
http://imageshack.us/photo/my-images/694/cuttingfail2.png/

Here is the code we use:

// temporary variables for cutting process
gp_Pnt ref;
TopoDS_Shape new_shape;
gp_Trsf aTrsf;

// calculate the planes' geometric center
double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
Bnd_Box B;
BRepBndLib::Add(cut_plane->shape()->Shape(), B);
B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
gp_Pnt cog((Xmax+Xmin)/2, (Ymax+Ymin)/2, (Zmax+Zmin)/2);

// scale the cutting plane to always cut all of the geometry
aTrsf.SetScale(cog, 1.0e4);
BRepBuilderAPI_Transform trfa(cut_plane->shape()->Shape(), aTrsf);
TopoDS_Face face = TopoDS::Face(trfa.Shape());

// create half space of entire model with face of cut_plane
TopoDS_Shape halfspace = BRepPrimAPI_MakeHalfSpace(face, ref).Solid();

// create new shape from referenced part and halfspace
BRepAlgoAPI_Common test(old_shape,halfspace);
new_shape = test.Shape();

cout if(test.HasGenerated()) cout

Jendrik Seiler's picture

Oh I forgot:
The error code always returns 0 but the generated output is not produced.

I hope there is someone who can support us with issue. Any help is greatly appreciated.

Alexander Luger's picture

Try to use ShapeFix_Solid on the cutting result.

Alex

Jendrik Seiler's picture

Thank you for your reply. Unfortunately, it was decided to implemend the cutting algorithm on another level and i can't test your idea at the moment. If I have a few minutes in the future i'll try it anyways and let you know whether it solves the problem.