Salome HOME
fac506fd1589fa20393a039e1e4749fe1dcfffbe
[modules/shaper.git] / src / GeomAPI / GeomAPI_ShapeExplorer.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAPI_ShapeExplorer.h
4 // Created:     5 June 2015
5 // Author:      Dmitry Bobylev
6
7 #ifndef GeomAPI_ShapeExplorer_H_
8 #define GeomAPI_ShapeExplorer_H_
9
10 #include <GeomAPI.h>
11 #include <GeomAPI_Shape.h>
12
13 /** \class GeomAPI_ShapeExplorer
14  *  \ingroup DataModel
15  *  \brief This class is used to explore subshapes on shape.
16  */
17
18 class GeomAPI_ShapeExplorer : public GeomAPI_Interface
19 {
20 public:
21   /// Default constructor. Creates an empty explorer, becomes usefull after Init.
22   GEOMAPI_EXPORT 
23   GeomAPI_ShapeExplorer();
24
25   /** \brief Constructs an explorer to search on theShape, for shapes of type toFind,
26    *  that are not part of a shape toAvoid. If the shape toAvoid is equal to GeomAPI_SHape::SHAPE,
27    *  or if it is the same as, or less complex than the shape toFind it has no effect on the search.
28       \param[in] toFind shape type to find.
29       \param[in] toAvoid shape type to avoid.
30    */
31   GEOMAPI_EXPORT 
32   GeomAPI_ShapeExplorer(const std::shared_ptr<GeomAPI_Shape>& theShape,
33                         const GeomAPI_Shape::ShapeType toFind,
34                         const GeomAPI_Shape::ShapeType toAvoid = GeomAPI_Shape::SHAPE);
35
36   /** \brief Resets this explorer. It is initialized to search on theShape, for shapes of type toFind,
37    *  that are not part of a shape toAvoid. If the shape toAvoid is equal to GeomAPI_SHape::SHAPE,
38    *  or if it is the same as, or less complex than the shape toFind it has no effect on the search.
39       \param[in] toFind shape type to find.
40       \param[in] toAvoid shape type to avoid.
41    */
42   GEOMAPI_EXPORT 
43   void init(const std::shared_ptr<GeomAPI_Shape>& theShape,
44             const GeomAPI_Shape::ShapeType toFind,
45             const GeomAPI_Shape::ShapeType toAvoid = GeomAPI_Shape::SHAPE);
46
47   /// \return true if there are more shapes in the exploration.
48   GEOMAPI_EXPORT 
49   bool more() const;
50
51   /// Moves to the next Shape in the exploration or do nothing if there are no more shapes to explore.
52   GEOMAPI_EXPORT 
53   void next();
54
55   /// Returns the current shape in the exploration or empty pointer if this explorer has no more shapes to explore.
56   GEOMAPI_EXPORT 
57   std::shared_ptr<GeomAPI_Shape> current();
58
59   /// Reinitialize the exploration with the original arguments.
60   GEOMAPI_EXPORT 
61   void reinit();
62
63   /// Returns the current depth of the exploration. 0 is the shape to explore itself.
64   GEOMAPI_EXPORT 
65   int depth() const;
66
67   /// Clears the content of the explorer. It will return False on more().
68   GEOMAPI_EXPORT 
69   void clear();
70
71 };
72
73 #endif