Salome HOME
Replace void* with shared_ptr<void> in GeomAPI_Interface
[modules/shaper.git] / src / GeomAPI / GeomAPI_ShapeExplorer.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAPI_ShapeExplorer.cpp
4 // Created:     5 June 2015
5 // Author:      Dmitry Bobylev
6
7 #include <GeomAPI_ShapeExplorer.h>
8
9 #include <Standard_NoMoreObject.hxx>
10 #include <TopExp_Explorer.hxx>
11
12 #define MY_EXPLORER implPtr<TopExp_Explorer>()
13
14 //=================================================================================================
15 GeomAPI_ShapeExplorer::GeomAPI_ShapeExplorer()
16 : GeomAPI_Interface(new TopExp_Explorer())
17 {
18 }
19
20 //=================================================================================================
21 GeomAPI_ShapeExplorer::GeomAPI_ShapeExplorer(const std::shared_ptr<GeomAPI_Shape>& theShape,
22                                              const GeomAPI_Shape::ShapeType toFind,
23                                              const GeomAPI_Shape::ShapeType toAvoid)
24 : GeomAPI_Interface(new TopExp_Explorer(theShape->impl<TopoDS_Shape>(),
25                                        (TopAbs_ShapeEnum)toFind,
26                                        (TopAbs_ShapeEnum)toAvoid))
27 {
28 }
29
30 //=================================================================================================
31 void GeomAPI_ShapeExplorer::init(const std::shared_ptr<GeomAPI_Shape>& theShape,
32                                  const GeomAPI_Shape::ShapeType toFind,
33                                  const GeomAPI_Shape::ShapeType toAvoid)
34 {
35   MY_EXPLORER->Init(theShape->impl<TopoDS_Shape>(),
36                    (TopAbs_ShapeEnum)toFind,
37                    (TopAbs_ShapeEnum)toAvoid);
38 }
39
40 //=================================================================================================
41 bool GeomAPI_ShapeExplorer::more() const
42 {
43   return MY_EXPLORER->More() == Standard_True;
44 }
45
46 //=================================================================================================
47 void GeomAPI_ShapeExplorer::next()
48 {
49   try {
50     MY_EXPLORER->Next();
51   } catch (Standard_NoMoreObject) {
52   }
53 }
54
55 //=================================================================================================
56 std::shared_ptr<GeomAPI_Shape> GeomAPI_ShapeExplorer::current()
57 {
58   try {
59     const TopoDS_Shape& aShape = MY_EXPLORER->Current();
60     std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape());
61     aGeomShape->setImpl(new TopoDS_Shape(aShape));
62     return aGeomShape;
63   } catch (Standard_NoMoreObject) {
64     return std::shared_ptr<GeomAPI_Shape>();
65   }
66 }
67
68 //=================================================================================================
69 void GeomAPI_ShapeExplorer::reinit()
70 {
71   MY_EXPLORER->ReInit();
72 }
73
74 //=================================================================================================
75 int GeomAPI_ShapeExplorer::depth() const
76 {
77   return MY_EXPLORER->Depth();
78 }
79
80 //=================================================================================================
81 void GeomAPI_ShapeExplorer::clear()
82 {
83   MY_EXPLORER->Clear();
84 }