Iusses computing a cut from a prism and a sphere.

In the code bellow I cut a sphere from a prism. In one particular setup this does not return the expected cut but the complete prism with a arc from the intersecting sphere on it's surface.
My question is if the cut generated with gp_Pnt origin = gp_Pnt(1,0,0); is expected on and if so how would one get a cut that is more like the one I see with gp_Pnt origin = gp_Pnt(0,0,0);?

--------------- demo_simple_07.cpp --------------

#include
#include
#include
#include
#include
#include
#include
#include
#include

int main()
{
/* Sphere */

// works as expected
// gp_Pnt origin = gp_Pnt(0,0,0);

// does not work
gp_Pnt origin = gp_Pnt(1,0,0);

Standard_Real radius = 1.;
TopoDS_Shape s1 = BRepPrimAPI_MakeSphere(origin, radius).Shape();

/* Prism */
gp_Pnt b1 = gp_Pnt(1, 0, 1);
gp_Pnt b2 = gp_Pnt(0, 0, 0);
gp_Pnt b3 = gp_Pnt(2, 0, 0);
TopoDS_Wire wire = BRepBuilderAPI_MakePolygon(b1, b2, b3, Standard_True).Wire();
TopoDS_Face base = BRepBuilderAPI_MakeFace(wire, Standard_True);
gp_Pnt gp1 = gp_Pnt(1., 0., 0.3333333);
gp_Pnt gp2 = gp_Pnt(1., 2., 0.3333333);
gp_Vec vec = gp_Vec(gp1, gp2);
TopoDS_Shape s2 = BRepPrimAPI_MakePrism(base, vec, Standard_True, Standard_True).Shape();

TopoDS_Shape shape = BRepAlgoAPI_Cut(s2, s1).Shape();

/* write */
STEPControl_Writer writer;
writer.Transfer(shape, STEPControl_ManifoldSolidBrep);
if ( !writer.Write( "test.step")) {
return 1;
}
return 0;
}

--------------

I compile this with

g++ -I ~/ooc/install/include/opencascade/ -L ~/ooc/install/lib/ demo_simple_07.cpp -lTKBin -lTKBinL -lTKBinTObj -lTKBinXCAF -lTKBO -lTKBool -lTKBRep -lTKCAF -lTKCDF -lTKDCAF -lTKDraw -lTKernel -lTKFeat -lTKFillet -lTKG2d -lTKG3d -lTKGeomAlgo -lTKGeomBase -lTKHLR -lTKIGES -lTKLCAF -lTKMath -lTKMesh -lTKMeshVS -lTKOffset -lTKOpenGl -lTKPrim -lTKQADraw -lTKRWMesh -lTKService -lTKShHealing -lTKStd -lTKStdL -lTKSTEP209 -lTKSTEP -lTKSTEPAttr -lTKSTEPBase -lTKSTL -lTKTObj -lTKTObjDRAW -lTKTopAlgo -lTKTopTest -lTKV3d -lTKVCAF -lTKViewerTest -lTKVRML -lTKXCAF -lTKXDEDRAW -lTKXDEIGES -lTKXDESTEP -lTKXMesh -lTKXml -lTKXmlL -lTKXmlTObj -lTKXmlXCAF -lTKXSBase -lTKXSDRAW

Thanks.

Attachments: 
Oliver R's picture

Sorry, somehow the includes get messed up. I have added a space after the initial < to get them to display

#include < gp_Ax2.hxx>
#include < TopoDS_Shape.hxx>
#include < BRepPrimAPI_MakeSphere.hxx>
#include < BRepPrimAPI_MakePrism.hxx>
#include < BRepBuilderAPI_MakePolygon.hxx>
#include < BRepBuilderAPI_MakeFace.hxx>
#include < BRepAlgoAPI_Cut.hxx>
#include < STEPControl_Reader.hxx>
#include < STEPControl_Writer.hxx>