File: boolean_ops.cpp

package info (click to toggle)
oce 0.18.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 301,548 kB
  • sloc: cpp: 1,190,609; ansic: 67,225; sh: 11,630; tcl: 7,954; cs: 5,221; python: 2,867; java: 1,522; makefile: 342; xml: 292; perl: 37
file content (39 lines) | stat: -rw-r--r-- 1,356 bytes parent folder | download | duplicates (7)
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();
}