summaryrefslogtreecommitdiff
path: root/test/BRepAlgoAPI_test/boolean_ops.cpp
blob: 3d03ac2e1636aecffcb59520311f60a545dcc56d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
#include <BRepAlgoAPI_Cut.hxx>

#include <gtest/gtest.h>

TEST(BRepAlgoAPITestSuite, testCutBox)
{
    // create the first shape: a cube, a corner at the origin
    TopoDS_Solid box1 = (TopoDS_Solid) BRepPrimAPI_MakeBox(10.,10.,10.);
    ASSERT_FALSE(box1.IsNull());
    // the second shape: a smaller cube, a corner at the origin
    TopoDS_Solid box2 = (TopoDS_Solid) BRepPrimAPI_MakeBox(5.,5.,5.);
    ASSERT_FALSE(box2.IsNull());
    // boolean cut
    TopoDS_Shape shp_result = BRepAlgoAPI_Cut(box1,box2);
    ASSERT_FALSE(shp_result.IsNull());
    TopoDS_Shape shp_result2 = BRepAlgoAPI_Cut(box2,box1);
    ASSERT_FALSE(shp_result2.IsNull());
}

TEST(BRepAlgoAPITestSuite, testCutCylSphere)
{
    // create the first shape: a sphere, centered at the origin
    TopoDS_Solid sphere = BRepPrimAPI_MakeSphere(10.);
    ASSERT_FALSE(sphere.IsNull());
    // the second shape: a cylinder cube, a corner at the origin
    TopoDS_Solid cylinder = BRepPrimAPI_MakeCylinder(5.,15.);
    ASSERT_FALSE(cylinder.IsNull());
    // boolean cut
    TopoDS_Shape shp_result = BRepAlgoAPI_Cut(sphere,cylinder);
    ASSERT_FALSE(shp_result.IsNull());
}

int main(int argc, char **argv){
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}