Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/misc/brepsamples/spheres_in_cylinder.cpp
3196 views
1
// compilation: just include all occ-headers and link against all occ-libs
2
3
#include "occheaders.h"
4
5
int main()
6
{
7
// make a cylinder:
8
//------------------
9
gp_Pnt orig(0, 0, 0);
10
gp_Dir normal(0, 0, 1);
11
Standard_Real radius = 0.25;
12
Standard_Real height = 1.0;
13
14
gp_Ax2 axis(orig, normal);
15
TopoDS_Shape cylinder = BRepPrimAPI_MakeCylinder(axis, radius, height);
16
17
// make a sphere:
18
//---------------
19
gp_Pnt sphere_orig(0.15, 0, 0.75);
20
Standard_Real sphere_radius = 0.025;
21
22
TopoDS_Shape sphere = BRepPrimAPI_MakeSphere(sphere_orig, sphere_radius);
23
24
// make another sphere:
25
//---------------------
26
gp_Pnt sphere_orig2(0, 0.15, 0.8);
27
Standard_Real sphere_radius2 = 0.025;
28
29
TopoDS_Shape sphere2 = BRepPrimAPI_MakeSphere(sphere_orig2, sphere_radius2);
30
31
// subtract sphere from cylinder:
32
//--------------------------------
33
BRepAlgoAPI_Cut tmp(cylinder, sphere);
34
cylinder = tmp.Shape();
35
36
BRepAlgoAPI_Cut tmp2(cylinder, sphere2);
37
cylinder = tmp2.Shape();
38
39
// write result in brep file:
40
//---------------------------
41
BRepTools::Write(cylinder, "sedimentation.brep");
42
43
return 0;
44
}
45
46