Salome HOME
Improve ExchangePlugin code coverage
[modules/shaper.git] / src / GeomAPI / GeomAPI_ShapeExplorer.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef GeomAPI_ShapeExplorer_H_
22 #define GeomAPI_ShapeExplorer_H_
23
24 #include <GeomAPI.h>
25 #include <GeomAPI_Shape.h>
26
27 /** \class GeomAPI_ShapeExplorer
28  *  \ingroup DataModel
29  *  \brief This class is used to explore subshapes on shape.
30  */
31 class GeomAPI_ShapeExplorer : public GeomAPI_Interface
32 {
33 public:
34   /// Default constructor. Creates an empty explorer, becomes usefull after Init.
35   GEOMAPI_EXPORT
36   GeomAPI_ShapeExplorer();
37
38   /** \brief Constructs an explorer to search on theShape, for shapes of type toFind,
39    *  that are not part of a shape toAvoid. If the shape toAvoid is equal to GeomAPI_SHape::SHAPE,
40    *  or if it is the same as, or less complex than the shape toFind it has no effect on the search.
41    *  \param[in] theShape shape to explore.
42    *  \param[in] toFind shape type to find.
43    *  \param[in] toAvoid shape type to avoid.
44    */
45   GEOMAPI_EXPORT
46   GeomAPI_ShapeExplorer(const std::shared_ptr<GeomAPI_Shape>& theShape,
47                         const GeomAPI_Shape::ShapeType toFind,
48                         const GeomAPI_Shape::ShapeType toAvoid = GeomAPI_Shape::SHAPE);
49
50   /** \brief Resets this explorer. It is initialized to search on theShape, for shapes of type toFind,
51    *  that are not part of a shape toAvoid. If the shape toAvoid is equal to GeomAPI_SHape::SHAPE,
52    *  or if it is the same as, or less complex than the shape toFind it has no effect on the search.
53    *  \param[in] theShape shape to explore.
54    *  \param[in] toFind shape type to find.
55    *  \param[in] toAvoid shape type to avoid.
56    */
57   GEOMAPI_EXPORT
58   void init(const std::shared_ptr<GeomAPI_Shape>& theShape,
59             const GeomAPI_Shape::ShapeType toFind,
60             const GeomAPI_Shape::ShapeType toAvoid = GeomAPI_Shape::SHAPE);
61
62   /// \return true if there are more shapes in the exploration.
63   GEOMAPI_EXPORT
64   bool more() const;
65
66   /// Moves to the next Shape in the exploration or do nothing
67   /// if there are no more shapes to explore.
68   GEOMAPI_EXPORT
69   void next();
70
71   /// \return the current shape in the exploration or empty pointer
72   /// if this explorer has no more shapes to explore.
73   GEOMAPI_EXPORT
74   std::shared_ptr<GeomAPI_Shape> current();
75
76   /// Reinitialize the exploration with the original arguments.
77   GEOMAPI_EXPORT
78   void reinit();
79
80   /// \return the current depth of the exploration. 0 is the shape to explore itself.
81   GEOMAPI_EXPORT
82   int depth() const;
83
84   /// Clears the content of the explorer. It will return False on more().
85   GEOMAPI_EXPORT
86   void clear();
87
88 };
89
90 #endif