Path: blob/devel/misc/brepsamples/spheres_in_cylinder.cpp
3196 views
// compilation: just include all occ-headers and link against all occ-libs12#include "occheaders.h"34int main()5{6// make a cylinder:7//------------------8gp_Pnt orig(0, 0, 0);9gp_Dir normal(0, 0, 1);10Standard_Real radius = 0.25;11Standard_Real height = 1.0;1213gp_Ax2 axis(orig, normal);14TopoDS_Shape cylinder = BRepPrimAPI_MakeCylinder(axis, radius, height);1516// make a sphere:17//---------------18gp_Pnt sphere_orig(0.15, 0, 0.75);19Standard_Real sphere_radius = 0.025;2021TopoDS_Shape sphere = BRepPrimAPI_MakeSphere(sphere_orig, sphere_radius);2223// make another sphere:24//---------------------25gp_Pnt sphere_orig2(0, 0.15, 0.8);26Standard_Real sphere_radius2 = 0.025;2728TopoDS_Shape sphere2 = BRepPrimAPI_MakeSphere(sphere_orig2, sphere_radius2);2930// subtract sphere from cylinder:31//--------------------------------32BRepAlgoAPI_Cut tmp(cylinder, sphere);33cylinder = tmp.Shape();3435BRepAlgoAPI_Cut tmp2(cylinder, sphere2);36cylinder = tmp2.Shape();3738// write result in brep file:39//---------------------------40BRepTools::Write(cylinder, "sedimentation.brep");4142return 0;43}444546