]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp
Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Boolean.cpp
1 // File:        GeomAlgoAPI_Boolean.cpp
2 // Created:     02 Sept 2014
3 // Author:      Vitaly Smetannikov
4
5 #include "GeomAlgoAPI_Boolean.h"
6
7 #include <BRepAlgoAPI_Cut.hxx>
8 #include <BRepAlgoAPI_Common.hxx>
9 #include <BRepAlgoAPI_Fuse.hxx>
10
11
12 boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Boolean::makeCut(
13   boost::shared_ptr<GeomAPI_Shape> theShape,
14   boost::shared_ptr<GeomAPI_Shape> theTool)
15 {
16   const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
17   const TopoDS_Shape& aTool = theTool->impl<TopoDS_Shape>();
18
19   BRepAlgoAPI_Cut aCut(aShape, aTool);
20   if (aCut.IsDone()) {
21     boost::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape());
22     aResult->setImpl(new TopoDS_Shape(aCut.Shape()));
23     return aResult;
24   }
25   return boost::shared_ptr<GeomAPI_Shape>();
26 }
27
28
29 boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Boolean::makeFuse(
30   boost::shared_ptr<GeomAPI_Shape> theShape,
31   boost::shared_ptr<GeomAPI_Shape> theTool)
32 {
33   const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
34   const TopoDS_Shape& aTool = theTool->impl<TopoDS_Shape>();
35
36   BRepAlgoAPI_Fuse aFuse(aShape, aTool);
37   if (aFuse.IsDone()) {
38     boost::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape());
39     aResult->setImpl(new TopoDS_Shape(aFuse.Shape()));
40     return aResult;
41   }
42   return boost::shared_ptr<GeomAPI_Shape>();
43 }
44
45
46 boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Boolean::makeCommon(
47   boost::shared_ptr<GeomAPI_Shape> theShape,
48   boost::shared_ptr<GeomAPI_Shape> theTool)
49 {
50   const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
51   const TopoDS_Shape& aTool = theTool->impl<TopoDS_Shape>();
52
53   BRepAlgoAPI_Common aCommon(aShape, aTool);
54   if (aCommon.IsDone()) {
55     boost::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape());
56     aResult->setImpl(new TopoDS_Shape(aCommon.Shape()));
57     return aResult;
58   }
59   return boost::shared_ptr<GeomAPI_Shape>();
60 }